-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use now flask-restx and no more flask-restplus Add multiple authentication methode
- Loading branch information
Showing
17 changed files
with
123 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
waitress==1.4.3 | ||
flask==1.1.2 | ||
flask-restplus==0.13.0 | ||
flask-jwt-extended==3.24.1 | ||
waitress==2.0.0 | ||
flask==2.0.1 | ||
flask-restx==0.5.1 | ||
flask-jwt-extended==4.3.0 | ||
flask-basicauth==0.2.0 | ||
SQLAlchemy==1.3.17 | ||
SQLAlchemy-Utils==0.36.6 | ||
python-gammu==2.12 | ||
mysqlclient==1.4.6 | ||
|
||
# Fix bug in flask | ||
werkzeug==0.16.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from server.instance import server | ||
from flask_jwt_extended import ( verify_jwt_in_request ) | ||
from flask_basicauth import BasicAuth | ||
|
||
app = server.app | ||
basic_auth = BasicAuth(app) | ||
|
||
def required_bearerAuth(bearerAuth = True): | ||
def decorator(fn): | ||
def decorated(*args,**kwargs): | ||
if bearerAuth: | ||
verify_jwt_in_request() | ||
return fn(*args,**kwargs) | ||
return decorated | ||
return decorator | ||
|
||
def required_basicAuth(basicAuth = True): | ||
def decorator(fn): | ||
def decorated(*args,**kwargs): | ||
if basicAuth: | ||
if not basic_auth.authenticate(): | ||
return {'message': 'Basic authenfication fail', 'details': 'Wrong username or password.'}, 401 | ||
return fn(*args,**kwargs) | ||
return decorated | ||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.