Security
application_kit.fastapi.security
FastAPIAuthenticateBase
FastAPIAuthenticateBase(
classes=None,
token_lambda=None,
product=None,
write_permission_needed=None,
endpoint_mode=UNSET,
)
Bases: AuthenticateBase
Base class to implement Authentication dependencies.
| PARAMETER | DESCRIPTION |
|---|---|
product
|
The products required to be activated on the project.
TYPE:
|
write_permission_needed
|
Deprecated use endpoint_mode instead.
TYPE:
|
endpoint_mode
|
Controls what kind of permissions are required from the ProjectToken.
TYPE:
|
Source code in application_kit/authenticator/base.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_project_token
get_project_token(
current_product,
headers,
key_token,
kind,
request_method,
port,
organization_id=None,
project_id=None,
)
Calls authentication service to get a token for an incoming request.
| PARAMETER | DESCRIPTION |
|---|---|
headers
|
The headers mapping from the request
TYPE:
|
kind
|
The kind of token detected.
TYPE:
|
organization_id
|
organization_id coming from the request path, used with user tokens.
TYPE:
|
project_id
|
project_id coming from the request path, used with user tokens.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ProjectTokenModel, TokenModel]
|
Returns ProjectTokenModel and a TokenModel, the later will be retired. |
Source code in application_kit/authenticator/base.py
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 | |
perform_instance_checks
perform_instance_checks(
project_token, headers, request_method
)
Performs permissions, and restrictions checks, returns extra response headers.
Source code in application_kit/authenticator/base.py
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 | |
AuthenticateKey
AuthenticateKey(product=None, write_permission_needed=None)
Bases: FastAPIAuthenticateBase
AuthenticateKey authenticate a request using key, private_key, X-Api-Key.
Source code in application_kit/fastapi/security.py
95 96 | |
get_project_token
get_project_token(
current_product,
headers,
key_token,
kind,
request_method,
port,
organization_id=None,
project_id=None,
)
Calls authentication service to get a token for an incoming request.
| PARAMETER | DESCRIPTION |
|---|---|
headers
|
The headers mapping from the request
TYPE:
|
kind
|
The kind of token detected.
TYPE:
|
organization_id
|
organization_id coming from the request path, used with user tokens.
TYPE:
|
project_id
|
project_id coming from the request path, used with user tokens.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ProjectTokenModel, TokenModel]
|
Returns ProjectTokenModel and a TokenModel, the later will be retired. |
Source code in application_kit/authenticator/base.py
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 | |
perform_instance_checks
perform_instance_checks(
project_token, headers, request_method
)
Performs permissions, and restrictions checks, returns extra response headers.
Source code in application_kit/authenticator/base.py
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 | |
AuthenticateWritePrivateKey
AuthenticateWritePrivateKey(product=None)
Bases: FastAPIAuthenticateBase
AuthenticatePrivateKey authenticate a request using private_key, X-Api-Key requires write_permission.
Source code in application_kit/fastapi/security.py
118 119 | |
get_project_token
get_project_token(
current_product,
headers,
key_token,
kind,
request_method,
port,
organization_id=None,
project_id=None,
)
Calls authentication service to get a token for an incoming request.
| PARAMETER | DESCRIPTION |
|---|---|
headers
|
The headers mapping from the request
TYPE:
|
kind
|
The kind of token detected.
TYPE:
|
organization_id
|
organization_id coming from the request path, used with user tokens.
TYPE:
|
project_id
|
project_id coming from the request path, used with user tokens.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ProjectTokenModel, TokenModel]
|
Returns ProjectTokenModel and a TokenModel, the later will be retired. |
Source code in application_kit/authenticator/base.py
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 | |
perform_instance_checks
perform_instance_checks(
project_token, headers, request_method
)
Performs permissions, and restrictions checks, returns extra response headers.
Source code in application_kit/authenticator/base.py
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 | |
AuthenticateUser
AuthenticateUser(classes=None, product=None)
Bases: FastAPIAuthenticateBase
AuthenticateUser authenticate a request using User bearer token found in Authorization header.
Source code in application_kit/fastapi/security.py
140 141 | |
get_project_token
get_project_token(
current_product,
headers,
key_token,
kind,
request_method,
port,
organization_id=None,
project_id=None,
)
Calls authentication service to get a token for an incoming request.
| PARAMETER | DESCRIPTION |
|---|---|
headers
|
The headers mapping from the request
TYPE:
|
kind
|
The kind of token detected.
TYPE:
|
organization_id
|
organization_id coming from the request path, used with user tokens.
TYPE:
|
project_id
|
project_id coming from the request path, used with user tokens.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ProjectTokenModel, TokenModel]
|
Returns ProjectTokenModel and a TokenModel, the later will be retired. |
Source code in application_kit/authenticator/base.py
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 | |
perform_instance_checks
perform_instance_checks(
project_token, headers, request_method
)
Performs permissions, and restrictions checks, returns extra response headers.
Source code in application_kit/authenticator/base.py
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 | |
AuthenticationErrorResponse
Bases: BaseModel
AuthenticationErrorResponse is the base authentication error model.