Skip to content

Commit

Permalink
Merge pull request #7 from RDCH106/develop
Browse files Browse the repository at this point in the history
Add CORS
  • Loading branch information
RDCH106 authored Oct 10, 2017
2 parents 629056d + 3ea3ed2 commit c1a0fa3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions linkero/config/config-scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"certificate" : "ssl/cert_file.crt",
"key" : "ssl/key_file.key"
},
"CORS" : {
"enable" : true,
"origins" : "*"
},
"gevent" : {
"spawn" : 10000
},
Expand Down
4 changes: 4 additions & 0 deletions linkero/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"activate" : false,
"certificate" : "ssl/cert_file.crt",
"key" : "ssl/key_file.key"
},
"CORS" : {
"enable" : true,
"origins" : "*"
},
"gevent" : {
"spawn" : 10000
Expand Down
2 changes: 1 addition & 1 deletion linkero/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Metadata:
def __init__(self):
self.__version__ = '0.9.2'
self.__version__ = '0.9.3'
self.__author__ = 'Rubén de Celis Hernández'

def get_version(self):
Expand Down
5 changes: 5 additions & 0 deletions linkero/core/linkero.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from flask_restful import reqparse, abort, Api, Resource, fields, marshal
from flask_sqlalchemy import SQLAlchemy
from flask_httpauth import HTTPBasicAuth
from flask_cors import CORS
from passlib.apps import custom_app_context as pwd_context
from itsdangerous import (TimedJSONWebSignatureSerializer
as Serializer, BadSignature, SignatureExpired)
Expand Down Expand Up @@ -33,6 +34,8 @@
tokenLife = config["tokenLife"] # In seconds
adminSecret = config["adminSecret"]
checkDefaultAdminSecret(adminSecret)
cors = config["CORS"]["enable"]
origins = config["CORS"]["origins"]
debug = config["debug"]
except KeyError:
print(bcolors.WARNING+"Misformed config.json!"+bcolors.ENDC)
Expand All @@ -42,6 +45,8 @@
db = SQLAlchemy(app)
auth = HTTPBasicAuth()
api = Api(app)
if cors:
CORS(app, origins=origins)


class User(db.Model):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
flask-restful==0.3.5
flask-sqlalchemy==2.1
flask-httpauth==3.1.2
flask-cors==3.0.3
passlib==1.6.5
itsdangerous==0.24
gevent>=1.2.1
Expand Down

0 comments on commit c1a0fa3

Please sign in to comment.