-
-
Notifications
You must be signed in to change notification settings - Fork 493
Description
Describe the feature
Adding Custom Validators to Grants is doable by using the GrantType
interface (see https://github.com/oauthlib/oauthlib/blob/v2.1.0/oauthlib/oauth2/rfc6749/grant_types/base.py#L49-L56). However, we provide pre_configured
classes which does not expose "easily" these grant types. Also, we have multiple different kind of "hooks", for Server.__init__()
we have token_generator=hook
, token_expires_in=hook
, refresh_token_generator=hook
. Then for GrantTypeBase
have custom_validators (dict)
(pre_auth
/post_auth
/pre_token
/post_token
), register_code_modifier(hook)
and register_token_modifier(hook)
.
It is complicated for OAuth2 provider implementation but become worst when using the OpenID Connect openid.pre_configured
which has 8 GrantTypeBase
and 3 Dispatchers
, where each Dispatcher
has two Grant
with different names (e.g. default_auth_grant
or default_implicit_grant
).
E.g. Current OAuth2 Provider example:
oauthlib_server = oauth2.Server(..)
oauthlib_server._response_types["token"].custom_validators.pre_auth.append(myhook)
oauthlib_server._response_types["code"].custom_validators.pre_auth.append(myhook)
oauthlib_server._response_types["code"].register_code_modifier(mymodifier)
Same hooks with OpenID Provider is just impossible, or will span to more than 20 lines of code.
I open this issue to raise the problem and see what's the solutions we could imagine to progress toward a better place.
Additional context
It applies to OAuth2 Provider and OpenID Connect Provider server code.