@ -8,12 +8,31 @@ from api.models.tokens import AuthToken
|
||||
|
||||
|
||||
class TokenAuthentication(BaseAuthentication):
|
||||
""" API Token Authentication
|
||||
|
||||
Provides the ability to use the API by using a token to authenticate.
|
||||
"""
|
||||
|
||||
def authenticate_header(self, request):
|
||||
return 'Token'
|
||||
|
||||
|
||||
def authenticate(self, request):
|
||||
""" Authentication the API session using the supplied token
|
||||
|
||||
Args:
|
||||
request (object): API Request Object
|
||||
|
||||
Raises:
|
||||
exceptions.AuthenticationFailed: 'Token header invalid' - Authorization Header Value is not in format `Token <auth-token>`
|
||||
exceptions.AuthenticationFailed: 'Token header invalid. Possibly incorrectly formatted' - Authentication header value has >1 space
|
||||
exceptions.AuthenticationFailed: 'Invalid token header. Token string should not contain invalid characters.' - Authorization header contains non-unicode chars
|
||||
|
||||
Returns:
|
||||
None (None): User not authenticated
|
||||
tuple(user,token): User authenticated
|
||||
"""
|
||||
|
||||
auth = get_authorization_header(request).split()
|
||||
|
||||
if not auth:
|
||||
|
@ -8,6 +8,7 @@ about: https://gitlab.com/nofusscomputing/infrastructure/configuration-managemen
|
||||
|
||||
This section contains the application API documentation to assist in application development. The target audience is anyone whom would be developing the application.
|
||||
|
||||
- [Token Authentication](./token_authentication.md)
|
||||
|
||||
- [Models](./models/index.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
title: API Token Authentication
|
||||
description: No Fuss Computings django ITSM API Documentation for API Token Authentication
|
||||
date: 2024-06-29
|
||||
template: project.html
|
||||
about: https://gitlab.com/nofusscomputing/infrastructure/configuration-management/django_app
|
||||
---
|
||||
|
||||
::: app.api.auth.TokenAuthentication
|
||||
options:
|
||||
inherited_members: true
|
@ -66,6 +66,8 @@ nav:
|
||||
|
||||
- projects/django-template/development/api/index.md
|
||||
|
||||
- projects/django-template/development/api/token_authentication.md
|
||||
|
||||
- Models:
|
||||
|
||||
- projects/django-template/development/api/models/index.md
|
||||
|
Reference in New Issue
Block a user