diff options
| author | Brendan McCollam <bmccollam@uchicago.edu> | 2016-12-19 16:03:22 +0000 |
|---|---|---|
| committer | Brendan McCollam <bmccollam@uchicago.edu> | 2016-12-22 15:00:32 +0000 |
| commit | b63590317fc353da5e39ec9eef9a1494eddb925e (patch) | |
| tree | ebdc7fdd7673a2dfef9585c572c56b8222c37cd5 | |
| parent | ff0e40884f07fde16b542b883a3c5703092d6b86 (diff) | |
| download | oauthlib-b63590317fc353da5e39ec9eef9a1494eddb925e.tar.gz | |
Docs for custom validator registration
| -rw-r--r-- | docs/oauth2/grants/authcode.rst | 1 | ||||
| -rw-r--r-- | docs/oauth2/grants/credentials.rst | 1 | ||||
| -rw-r--r-- | docs/oauth2/grants/grants.rst | 6 | ||||
| -rw-r--r-- | docs/oauth2/grants/implicit.rst | 1 | ||||
| -rw-r--r-- | docs/oauth2/grants/password.rst | 1 | ||||
| -rw-r--r-- | oauthlib/oauth2/rfc6749/grant_types/base.py | 26 |
6 files changed, 36 insertions, 0 deletions
diff --git a/docs/oauth2/grants/authcode.rst b/docs/oauth2/grants/authcode.rst index c83e5a9..abf5d32 100644 --- a/docs/oauth2/grants/authcode.rst +++ b/docs/oauth2/grants/authcode.rst @@ -3,3 +3,4 @@ Authorization Code Grant .. autoclass:: oauthlib.oauth2.AuthorizationCodeGrant :members: + :inherited-members: diff --git a/docs/oauth2/grants/credentials.rst b/docs/oauth2/grants/credentials.rst index 790bce8..179c089 100644 --- a/docs/oauth2/grants/credentials.rst +++ b/docs/oauth2/grants/credentials.rst @@ -3,3 +3,4 @@ Client Credentials Grant .. autoclass:: oauthlib.oauth2.ClientCredentialsGrant :members: + :inherited-members: diff --git a/docs/oauth2/grants/grants.rst b/docs/oauth2/grants/grants.rst index 95d3ffe..f4fcb56 100644 --- a/docs/oauth2/grants/grants.rst +++ b/docs/oauth2/grants/grants.rst @@ -24,6 +24,12 @@ resources in various ways with different security credentials. Naturally, OAuth 2 allows for extension grant types to be defined and OAuthLib attempts to cater for easy inclusion of this as much as possible. +OAuthlib also offers hooks for registering your own custom validations for use +with the existing grant type handlers +(:py:meth:`oauthlib.oauth2.AuthorizationCodeGrant.register_authorization_validator`). +In some situations, this may be more convenient than subclassing or writing +your own extension grant type. + Certain grant types allow the issuing of refresh tokens which will allow a client to request new tokens for as long as you as provider allow them too. In general, OAuth 2 tokens should expire quickly and rather than annoying the user diff --git a/docs/oauth2/grants/implicit.rst b/docs/oauth2/grants/implicit.rst index 90490e3..6ffdc6e 100644 --- a/docs/oauth2/grants/implicit.rst +++ b/docs/oauth2/grants/implicit.rst @@ -3,3 +3,4 @@ Implicit Grant .. autoclass:: oauthlib.oauth2.ImplicitGrant :members: + :inherited-members: diff --git a/docs/oauth2/grants/password.rst b/docs/oauth2/grants/password.rst index 0230c09..48b42f6 100644 --- a/docs/oauth2/grants/password.rst +++ b/docs/oauth2/grants/password.rst @@ -3,3 +3,4 @@ Resource Owner Password Credentials Grant .. autoclass:: oauthlib.oauth2.ResourceOwnerPasswordCredentialsGrant :members: + :inherited-members: diff --git a/oauthlib/oauth2/rfc6749/grant_types/base.py b/oauthlib/oauth2/rfc6749/grant_types/base.py index 5a3888a..98b75e7 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/base.py +++ b/oauthlib/oauth2/rfc6749/grant_types/base.py @@ -44,12 +44,38 @@ class GrantTypeBase(object): self.response_types.append(response_type) def register_authorization_validator(self, validator, after_standard=True): + """ + Register a validator callable to be invoked during calls to the + authorization endpoint. + + :param callable validator: callable that takes a request object and returns a + mapping of items to be included with the authorization validation + response. + :param bool after_standard: default: True, If True, the custom + validator is called after the standard authorization + validations. If False, the custom valdator is called before + the standard validations. + :returns: None + """ if after_standard: self._auth_validators_run_after_standard_ones.append(validator) else: self._auth_validators_run_before_standard_ones.append(validator) def register_token_validator(self, validator, after_standard=True): + """ + Register a validator callable to be invoked during calls to the + token endpoint (or the authorization endpoint during the implicit grant, + flow which returns tokens directly from the authorization endpoint). + + + :param callable validator: callable that takes a request object and returns None or + raises an exception if appropriate. + :param bool after_standard: default: True, If True, the custom + validator is called after the standard token validations. If False, + the custom valdator is called before the standard validations. + :returns: None + """ if after_standard: self._token_validators_run_after_standard_ones.append(validator) else: |
