-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user object + validations Add login/registration/logout code Add authentication code Update tests to handle auth Add tests for auth Add pdiff tests
- Loading branch information
Showing
59 changed files
with
796 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from flask import request | ||
import flask.ext.restful | ||
from flask.ext.login import current_user | ||
|
||
from cycledash import login_manager | ||
from cycledash.auth import check_login | ||
|
||
|
||
class Resource(flask.ext.restful.Resource, object): | ||
"""Extends Resource by adding an authentication check for basic auth or | ||
valid session cokie. | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
self.auth = getattr(self, 'require_auth', False) | ||
super(Resource, self).__init__(*args, **kwargs) | ||
|
||
def dispatch_request(self, *args, **kwargs): | ||
if self.auth: | ||
authorized = False | ||
if login_manager._login_disabled: | ||
# This is used for tests. | ||
authorized = True | ||
elif current_user.is_authenticated(): | ||
authorized = True | ||
elif request.authorization: | ||
username = request.authorization.username | ||
password = request.authorization.password | ||
if check_login(username, password): | ||
authorized = True | ||
if not authorized: | ||
auth_msg = 'Correct username/password required.' | ||
return flask.ext.restful.abort(401, message=auth_msg) | ||
return super(Resource, self).dispatch_request(*args, **kwargs) | ||
|
||
|
||
import projects, bams, runs, genotypes, tasks, comments |
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
Oops, something went wrong.