Skip to content

Commit ecc8f2c

Browse files
committed
add management of disable_oauth resource option
1 parent bcea6ba commit ecc8f2c

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

flask_rest_jsonapi/api.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,28 @@ def before_request():
100100
endpoint = request.endpoint
101101
resource = self.app.view_functions[endpoint].view_class
102102

103-
scopes = None
103+
if not getattr(resource, 'disable_oauth'):
104+
scopes = request.args.get('scopes')
104105

105-
if request.args.get('scopes'):
106-
scopes = scopes.split(',')
107-
elif getattr(resource, 'schema'):
108-
scopes = [self.build_scope(resource, request.method)]
106+
if getattr(resource, 'schema'):
107+
scopes = [self.build_scope(resource, request.method)]
108+
elif scopes:
109+
scopes = scopes.split(',')
109110

110-
valid, req = oauth_manager.verify_request(scopes)
111+
if scopes:
112+
scopes = scopes.split(',')
111113

112-
for func in oauth_manager._after_request_funcs:
113-
valid, req = func(valid, req)
114+
valid, req = oauth_manager.verify_request(scopes)
114115

115-
if not valid:
116-
if oauth_manager._invalid_response:
117-
return oauth_manager._invalid_response(req)
118-
return abort(401)
116+
for func in oauth_manager._after_request_funcs:
117+
valid, req = func(valid, req)
119118

120-
request.oauth = req
119+
if not valid:
120+
if oauth_manager._invalid_response:
121+
return oauth_manager._invalid_response(req)
122+
return abort(401)
123+
124+
request.oauth = req
121125

122126
@staticmethod
123127
def build_scope(resource, method):

0 commit comments

Comments
 (0)