class documentation

class CredentialsManager: (source)

View In Hierarchy

A class to manage credentials for the CSE.

It is mainly managed and used by the SecurityManager to handle authentication and authorization of requests. It reads authentication data from specified files and provides methods to access this data for security checks.

It does not refresh the data automatically, so if the authentication files are updated, the respective read methods should be called again to refresh the data in memory.

Method addBasicAuthEntry Add HTTP basic authentication credentials to the file and update the in-memory data. The credentials are stored as username:password.
Method addTokenEntry Add HTTP or WebSocket token authentication credentials to the file and update the in-memory data. The credentials are stored as token.
Method deleteBasicAuthEntry Delete HTTP or WebSocket basic authentication credentials from the file and update the in-memory data. The credentials are stored as username:password.
Method deleteTokenEntry Delete HTTP or WebSocket token credentials from the file and update the in-memory data. The credentials are stored as token.
Method initialize Initialize the CertificateManager.
Method readHttpBasicAuthFile Read the HTTP basic authentication file and store the data in a dictionary. The authentication information is stored as username:password.
Method readHttpTokenFile Read the HTTP token authentication file and store the data in a dictionary. The authentication information is stored as a single token per line.
Method readWSBasicAuthFile Read the WebSocket basic authentication file and store the data in a dictionary. The authentication information is stored as username:password.
Method readWSTokenFile Read the WebSocket token authentication file and store the data in a dictionary. The authentication information is stored as a single token per line.
Method updateBasicAuthEntry Update HTTP or WebSocket basic authentication credentials in the file and update the in-memory data. The credentials are stored as username:password.
Method updateTokenEntry Update HTTP or WebSocket token authentication credentials in the file and update the in-memory data. The credentials are stored as token.
Class Variable __slots__ Slots for CertificateManager class.
Class Variable httpServer The injected HttpServer plugin instance.
Class Variable websocketServer The injected WebSocketServer plugin instance.
Instance Variable httpBasicAuthData Dictionary to store the HTTP Basic Authentication data, mapping originators to their hashed passwords.
Instance Variable httpTokenAuthData List to store the HTTP Token Authentication data.
Instance Variable wsBasicAuthData Dictionary to store the WebSocket Basic Authentication data, mapping originators to their hashed passwords.
Instance Variable wsTokenAuthData List to store the WebSocket Token Authentication data.
def addBasicAuthEntry(self, username: str, password: str, ty: BindingType): (source)

Add HTTP basic authentication credentials to the file and update the in-memory data. The credentials are stored as username:password.

Parameters
username:strThe username to add.
password:strThe password to add.
ty:BindingTypeThe type of credentials to add.
Raises
ValueErrorIf there is an error adding the credentials.
def addTokenEntry(self, token: str, ty: BindingType): (source)

Add HTTP or WebSocket token authentication credentials to the file and update the in-memory data. The credentials are stored as token.

Parameters
token:strThe token to add.
ty:BindingTypeThe type of credentials to add.
Raises
ValueErrorIf there is an error adding the credentials.
def deleteBasicAuthEntry(self, id: str, ty: BindingType): (source)

Delete HTTP or WebSocket basic authentication credentials from the file and update the in-memory data. The credentials are stored as username:password.

Parameters
id:strThe username or token to delete.
ty:BindingTypeUndocumented
Raises
ValueErrorIf there is an error deleting the credentials.
def deleteTokenEntry(self, token: str, ty: BindingType): (source)

Delete HTTP or WebSocket token credentials from the file and update the in-memory data. The credentials are stored as token.

Parameters
token:strThe token to delete.
ty:BindingTypeUndocumented
Raises
ValueErrorIf there is an error deleting the credentials.
def initialize(self): (source)

Initialize the CertificateManager.

def readHttpBasicAuthFile(self): (source)

Read the HTTP basic authentication file and store the data in a dictionary. The authentication information is stored as username:password.

The data is stored in the httpBasicAuthData dictionary.

Raises
ValueErrorIf there is an error reading the basic authentication file.
def readHttpTokenFile(self): (source)

Read the HTTP token authentication file and store the data in a dictionary. The authentication information is stored as a single token per line.

The data is stored in the httpTokenAuthData list.

Raises
ValueErrorIf there is an error reading the token authentication file.
def readWSBasicAuthFile(self): (source)

Read the WebSocket basic authentication file and store the data in a dictionary. The authentication information is stored as username:password.

The data is stored in the wsBasicAuthData dictionary.

Raises
ValueErrorIf there is an error reading the basic authentication file.
def readWSTokenFile(self): (source)

Read the WebSocket token authentication file and store the data in a dictionary. The authentication information is stored as a single token per line.

The data is stored in the wsTokenAuthData list.

Raises
ValueErrorIf there is an error reading the token authentication file.
def updateBasicAuthEntry(self, username: str, password: str, ty: BindingType): (source)

Update HTTP or WebSocket basic authentication credentials in the file and update the in-memory data. The credentials are stored as username:password.

Parameters
username:strThe username to update.
password:strThe new password to set.
ty:BindingTypeThe type of credentials to update.
Raises
ValueErrorIf there is an error updating the credentials.
def updateTokenEntry(self, token: str, nt: str, ty: BindingType): (source)

Update HTTP or WebSocket token authentication credentials in the file and update the in-memory data. The credentials are stored as token.

Parameters
token:strThe token to update.
nt:strThe new token to set.
ty:BindingTypeThe type of credentials to update.
__slots__: tuple[str, ...] = (source)

Slots for CertificateManager class.

The injected HttpServer plugin instance.

The injected WebSocketServer plugin instance.

httpBasicAuthData: dict[str, str] = (source)

Dictionary to store the HTTP Basic Authentication data, mapping originators to their hashed passwords.

httpTokenAuthData: list[str] = (source)

List to store the HTTP Token Authentication data.

wsBasicAuthData: dict[str, str] = (source)

Dictionary to store the WebSocket Basic Authentication data, mapping originators to their hashed passwords.

wsTokenAuthData: list[str] = (source)

List to store the WebSocket Token Authentication data.