Skip to content

Commit

Permalink
Allow a validate class to be passed into the OAuth2 Provider to be us…
Browse files Browse the repository at this point in the history
…ed instead of requiring an instance of a class
  • Loading branch information
claweyenuk committed Jun 6, 2018
1 parent 9082a19 commit 85b1da8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions flask_oauthlib/provider/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ def user():
return jsonify(request.oauth.user)
"""

def __init__(self, app=None):
def __init__(self, app=None, validator_class=None):
self._before_request_funcs = []
self._after_request_funcs = []
self._invalid_response = None
self._validator_class = validator_class
if app:
self.init_app(app)

Expand Down Expand Up @@ -155,7 +156,10 @@ def validate_client_id(self, client_id):
if hasattr(self, '_usergetter'):
usergetter = self._usergetter

validator = OAuth2RequestValidator(
validator_class = self._validator_class
if validator_class is None:
validator_class = OAuth2RequestValidator
validator = validator_class(
clientgetter=self._clientgetter,
tokengetter=self._tokengetter,
grantgetter=self._grantgetter,
Expand Down

0 comments on commit 85b1da8

Please sign in to comment.