Storage
Storage helper class for storing and retrieving client and resource owner information. See the examples on the sidebar to view this in action.
AuthorizationCodeStorage
Source code in aioauth/storage.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
create_authorization_code(*, request, client_id, scope, response_type, redirect_uri, code, code_challenge_method=None, code_challenge=None, nonce=None)
async
Generates an authorization token and stores it in the database.
Warning
Generated authorization token must be stored in the database.
Note
This must is used by the response type
aioauth.respose_type.ResponseTypeAuthorizationCode
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
An |
required |
client_id
|
str
|
A user client ID. |
required |
scope
|
str
|
The scopes for the token. |
required |
response_type
|
str
|
An |
required |
redirect_uri
|
str
|
The redirect URI. |
required |
code_challenge_method
|
Optional[CodeChallengeMethod]
|
An |
None
|
code_challenge
|
Optional[str]
|
Code challenge string. |
None
|
Returns:
Type | Description |
---|---|
AuthorizationCode
|
An |
Source code in aioauth/storage.py
delete_authorization_code(*, request, client_id, code)
async
Deletes authorization code from database.
Note
This method is used by the grant type
aioauth.grant_type.AuthorizationCodeGrantType
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
An |
required |
client_id
|
str
|
A user client ID. |
required |
code
|
str
|
An authorization code. |
required |
Source code in aioauth/storage.py
get_authorization_code(*, request, client_id, code)
async
Gets existing authorization code from the database if it exists.
Warning
If authorization code does not exists this function must
return None
to indicate to the validator that the
requested authorization code does not exist or is invalid.
Note
This method is used by the grant type
aioauth.grant_type.AuthorizationCodeGrantType
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
An |
required |
client_id
|
str
|
A user client ID. |
required |
code
|
str
|
An authorization code. |
required |
Returns:
Type | Description |
---|---|
Optional[AuthorizationCode]
|
An optional |
Source code in aioauth/storage.py
ClientStorage
Source code in aioauth/storage.py
get_client(*, request, client_id, client_secret=None)
async
Gets existing client from the database if it exists.
Warning
If client does not exists in database this method must
return None
to indicate to the validator that the
requested client_id
does not exist or is invalid.
Note
This method is used by all core grant types, as well as all core response types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
An |
required |
client_id
|
str
|
A user client ID. |
required |
client_secret
|
Optional[str]
|
An optional user client secret. |
None
|
Returns:
Type | Description |
---|---|
Optional[Client]
|
An optional |
Source code in aioauth/storage.py
IDTokenStorage
Source code in aioauth/storage.py
get_id_token(*, request, client_id, scope, redirect_uri, response_type=None, nonce=None)
async
Returns an id_token. For more information see OpenID Connect Core 1.0 incorporating errata set 1 section 2.
Note
Method is used by response type aioauth.response_type.ResponseTypeIdToken
and aioauth.oidc.core.grant_type.AuthorizationCodeGrantType
.
Source code in aioauth/storage.py
TokenStorage
Source code in aioauth/storage.py
create_token(*, request, client_id, scope, access_token, refresh_token=None)
async
Generates a user token and stores it in the database.
Used by:
ResponseTypeToken
AuthorizationCodeGrantType
PasswordGrantType
ClientCredentialsGrantType
RefreshTokenGrantType
Warning
Generated token must be stored in the database.
Note:
Method is used by all core grant types, but only used for
aioauth.response_type.ResponseTypeToken
.
Args:
request: An aioauth.requests.Request
.
client_id: A user client ID.
scope: The scopes for the token.
Returns:
The new generated aioauth.models.Token
.
Source code in aioauth/storage.py
get_token(*, request, client_id, token_type=None, access_token=None, refresh_token=None)
async
Gets existing token from the database.
Note
Method is used by
aioauth.server.AuthorizationServer
, and by the
grant type aioauth.grant_types.RefreshTokenGrantType
.
Args:
request: An aioauth.requests.Request
.
client_id: A user client ID.
access_token: The user access token.
refresh_token: The user refresh token.
Returns:
An optional aioauth.models.Token
object.
Source code in aioauth/storage.py
revoke_token(*, request, client_id, refresh_token=None, token_type=None, access_token=None)
async
Revokes a token from the database.
Source code in aioauth/storage.py
UserStorage
Source code in aioauth/storage.py
get_user(request)
async
Returns a user.
Note
This method is used by the grant type
aioauth.grant_type.PasswordGrantType
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Request
|
An |
required |
Returns:
Type | Description |
---|---|
Optional[Any]
|
Boolean indicating whether or not the user was authenticated |
Optional[Any]
|
successfully. |