-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/awg integration #209
Feat/awg integration #209
Changes from all commits
6c90b57
e3f57df
0c592fa
d5eb404
1439d27
1f49f1b
ac1a3d9
c41bd74
b407555
939543a
14eb092
8f77886
bb68ffb
4659a9a
2d71c45
77d2132
2d4b59e
00909df
1e86664
2f9a1c3
329675f
1b3d6b2
da6aebc
2341b16
e3d21a3
96f1209
0b637b6
0669a47
75e3413
8366cee
692fe5b
35c4f59
5c7fa7b
2131509
e367ad0
23bdd48
c1becc5
f5034e1
42b2368
c350981
33e17b7
842fedf
3b93ced
592d46e
88b515f
374a5fd
34d265d
230ee37
45c8081
6da7c4e
5df92b5
93f4401
555127b
9665ca7
c13836d
66e0f87
25cc961
1d45530
cefd836
3232948
d36342c
4ccd587
19515a7
4c3947a
e92b4c5
ffb8d3d
878ef0d
8529612
c25078e
7cf9122
028d053
b4d911b
fa9dae1
08d8fff
5c102bf
cd2c372
47fa6a3
a3d4ce8
ae108a8
192212c
26c021a
965373e
6a73560
75e6356
a5a542b
b54410d
3fc974b
500a336
52249e7
df5c10b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,13 +58,15 @@ def logout(next_url=None): | |
# Call get_current_user (but ignore the result) just to check that either | ||
# the user is logged in or that authorization is mocked. | ||
user = get_current_user() | ||
flask.current_app.logger.debug("IN AUTH LOGOUT, next_url = {0}".format(next_url)) | ||
if not user: | ||
raise Unauthorized("You are not logged in") | ||
itrust_next_url = None | ||
if flask.session.get('provider') == IdentityProvider.itrust: | ||
next_url = flask.current_app.config['ITRUST_GLOBAL_LOGOUT'] + next_url | ||
itrust_next_url = flask.current_app.config['ITRUST_GLOBAL_LOGOUT'] + next_url | ||
flask.session.clear() | ||
redirect_response = flask.make_response( | ||
flask.redirect(next_url) | ||
flask.redirect(itrust_next_url or next_url) | ||
) | ||
clear_cookies(redirect_response) | ||
return redirect_response | ||
|
@@ -84,6 +86,7 @@ def check_scope_and_call(*args, **kwargs): | |
return wrapper | ||
|
||
|
||
|
||
def login_required(scope=None): | ||
""" | ||
Create decorator to require a user session in shibboleth. | ||
|
@@ -184,3 +187,16 @@ def get_user_from_claims(claims): | |
.filter(User.id == claims['sub']) | ||
.first() | ||
) | ||
|
||
def admin_required(f): | ||
""" | ||
Require user to be an admin user. | ||
""" | ||
@wraps(f) | ||
def wrapper(*args, **kwargs): | ||
if not flask.g.user: | ||
raise Unauthorized("Require login") | ||
if flask.g.user.is_admin is not True: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if not flask.g.user.is_admin:
... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if wouldn't blow up it g.user has not been intialized somewhere else There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it isn't initialized then it should blow up anyways I think, the only case this is different is that if |
||
raise Unauthorized("Require admin user") | ||
return f(*args, **kwargs) | ||
return wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems peculiar to only check the csrf token if you don't have an authorization header... line 192.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can discuss if you have any specific concerns about it or a suggestion on how to improve it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to the issue I had originally opened.