request.authentication.base

Provides base authentication class using the Composite pattern for modular authentication.

Classes

AuthenticationComponent

Abstract base class for authentication components.

ClientCertificateAuthentication

Handles authentication via client certificates.

IDevIDAuthentication

Handles authentication via IDevID certificates.

CompositeAuthentication

Composite authenticator for grouping and executing multiple authentication methods.

Module Contents

class request.authentication.base.AuthenticationComponent[source]

Bases: abc.ABC

Abstract base class for authentication components.

abstractmethod authenticate(context)[source]

Authenticate a request using specific logic.

Parameters:

context (request.request_context.BaseRequestContext)

Return type:

devices.models.DeviceModel | None

class request.authentication.base.ClientCertificateAuthentication[source]

Bases: AuthenticationComponent, trustpoint.logger.LoggerMixin

Handles authentication via client certificates.

authenticate(context)[source]

Authenticate using the client certificate from the context.

Parameters:

context (request.request_context.BaseRequestContext)

Return type:

None

_raise_certificate_error(message, cause=None)[source]

Raise certificate authentication error with proper exception chaining.

Parameters:
  • message (str)

  • cause (Exception | None)

Return type:

Never

class request.authentication.base.IDevIDAuthentication[source]

Bases: AuthenticationComponent, trustpoint.logger.LoggerMixin

Handles authentication via IDevID certificates.

authenticate(context)[source]

Authenticate the request using the IDevID mechanism.

Parameters:

context (request.request_context.BaseRequestContext)

Return type:

None

_raise_idevid_error(message)[source]

Raise IDevID authentication error.

Parameters:

message (str)

Return type:

Never

class request.authentication.base.CompositeAuthentication[source]

Bases: AuthenticationComponent, trustpoint.logger.LoggerMixin

Composite authenticator for grouping and executing multiple authentication methods.

components: list[AuthenticationComponent] = [][source]
add(component)[source]

Add an authentication component to the composite.

Parameters:

component (AuthenticationComponent)

Return type:

None

remove(component)[source]

Remove an authentication component from the composite.

Parameters:

component (AuthenticationComponent)

Return type:

None

authenticate(context)[source]

Authenticate the request using all registered components.

Parameters:

context (request.request_context.BaseRequestContext)

Return type:

None