configurable port plus support for SSL

This commit is contained in:
azivner 2017-08-14 21:05:01 -04:00
parent f80f073874
commit 3c924afbca
7 changed files with 41 additions and 8 deletions

2
.gitignore vendored
View file

@ -6,3 +6,5 @@ yarn-error.log
app.pyc
demo.ncdb
config.ini
cert.key
cert.crt

View file

@ -1,8 +1,13 @@
[Network]
port=5000
certPath=cert.crt
certKeyPath=cert.key
[Login]
# Enter below credentials with with which you want to authenticate to Notecase web app
username=adam
username=your_username
# This is bcrypt password hash. You can use generate-password.py (in this directory) to hash your password
password-hash=$2b$12$4Ia5lYbbpOv3pxxdoDgjUeAJ9z4FhqyEhhX52ra78FH03wPGx8zGu
password-hash=$2b$12$FHT8keXp3BGTfzAV/VnrkuLpkwN8Vpj5iIh4RwCbHTNWYSBI9hGAK
[Sync]
sync-server-url=https://localhost:57201

16
generate-cert.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
openssl genrsa -des3 -out cert.key 2048
openssl req -new -key cert.key -out cert.csr
# Remove passphrase from key
cp cert.key cert.key.org
openssl rsa -in cert.key.org -out cert.key
# Generate self signed certificate
openssl x509 -req -days 730 -in cert.csr -signkey cert.key -out cert.crt
rm cert.key.org
rm cert.csr

6
run-debug.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/sh
export FLASK_DEBUG=0
export FLASK_APP=src/app.py
flask run

2
run.sh
View file

@ -1,6 +1,6 @@
#!/bin/sh
export FLASK_DEBUG=1
export FLASK_DEBUG=0
export FLASK_APP=src/app.py
flask run

View file

@ -42,6 +42,10 @@ config.read('config.ini')
user = User()
user.id = config['Login']['username']
port = config['Network']['port']
certPath = config['Network']['certPath']
certKeyPath = config['Network']['certKeyPath']
hashedPassword = config['Login']['password-hash'].encode('utf-8')
@app.route('/login', methods=['POST'])
@ -85,5 +89,5 @@ def load_user(user_id):
api.add_resource(Notes, '/notes/<string:note_id>')
if __name__ == '__main__':
app.run(host='0.0.0.0')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=port, ssl_context = (certPath, certKeyPath))

View file

@ -44,7 +44,7 @@
</div>
</div>
<link href="static/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
<script src="static/lib/bootstrap/js/bootstrap.js"></script>
<link href="stat/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
<script src="stat/lib/bootstrap/js/bootstrap.js"></script>
</body>
</html>