class SecurityManager(object):
This manager entity handles access to resources and requests.
| Method | check |
Check whether this is actually a correct update of the acpi attribute, and whether this is actually allowed. |
| Method | check |
Check whether an originator has the requested permissions to the ACP resource itself. |
| Method | check |
Check whether an originator has the requested permissions with this ACP. |
| Method | config |
Handle configuration updates. |
| Method | get |
Return the credentials for the Point of Access (POA) for the given CSE-ID. These credentials are used by the registrar CSE to access this hosting CSE, or by the hosting CSE to access the registrar CSE. ... |
| Method | get |
Depending on the configuration whether to use DTLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned. |
| Method | get |
Depending on the configuration whether to use TLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned. |
| Method | get |
Depending on the configuration whether to use TLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned. |
| Method | has |
Test whether an originator has access to a resource for the requested permission. |
| Method | has |
Check whether the originator has access to the PCU resource. This should be done to check the parent PCH, but the originator would be the same as the PCU, so we can optimize this a bit. |
| Method | initialize |
Initialize the SecurityManager. |
| Method | is |
Check whether the provided originator could be an AE-ID. |
| Method | is |
Check whether an Originator is in the provided list of allowed originators. This list may contain regex. |
| Method | restart |
Restart the Security manager service. |
| Method | shutdown |
Shutdown the SecurityManager. |
| Method | validate |
Validate the provided username and password against the configured HTTP basic authentication file. |
| Method | validate |
Validate the provided token against the configured HTTP token authentication file. |
| Method | validate |
Validate the provided username and password against the configured WebSocket basic authentication file. |
| Method | validate |
Validate the provided token against the configured WebSocket token authentication file. |
| Class Variable | __slots__ |
Slots for SecurityManager class. |
| Class Variable | dispatcher |
Injected Dispatcher instance. |
| Class Variable | http |
The injected HttpServer plugin instance. |
| Class Variable | storage |
Injected Storage instance. |
| Class Variable | websocket |
The injected WebSocketServer plugin instance. |
| Instance Variable | allowed |
List of allowed CSE originators that are allowed to access the CSEBase resource. |
| Instance Variable | http |
Dictionary to store the HTTP Basic Authentication data, mapping originators to their hashed passwords. |
| Instance Variable | http |
List to store the HTTP Token Authentication data. |
| Instance Variable | ws |
Dictionary to store the WebSocket Basic Authentication data, mapping originators to their hashed passwords. |
| Instance Variable | ws |
List to store the WebSocket Token Authentication data. |
| Method | _check |
Check whether an originator is in the list of acor entries. |
| Method | _get |
Depending on the configuration whether to use TLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned. |
| Method | _init |
Initialize the authentication information by reading the configured authentication files for HTTP and WebSocket. |
| Method | _read |
Read the HTTP basic authentication file and store the data in a dictionary. The authentication information is stored as username:password. |
| Method | _read |
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 | _read |
Read the WebSocket basic authentication file and store the data in a dictionary. The authentication information is stored as username:password. |
| Method | _read |
Read the WebSocket token authentication file and store the data in a dictionary. The authentication information is stored as a single token per line. |
CSERequest, targetResource: Resource, originator: str) -> bool:
¶
Check whether this is actually a correct update of the acpi attribute, and whether this is actually allowed.
- Raises
BAD_REQUEST: If the acpi attribute is not the only attribute in an UPDATE request.ORIGINATOR_HAS_NO_PRIVILEGE: If the originator has no access.
| Parameters | |
request:CSERequest | The original request. |
targetResource | The request target. |
originator:str | The request originator. |
| Returns | |
bool | Boolean value. True indicates that this is an ACPI update. False indicates that this NOT an ACPI update. if no access is provided then an exception is raised. |
ACP | ACPAnnc, originator: str, requestedPermission: Permission) -> bool:
¶
Check whether an originator has the requested permissions to the ACP resource itself.
| Parameters | |
acp:ACP | ACPAnnc | Undocumented |
originator:str | The originator to test the permissions for. |
requestedPermission | The permissions to test. |
| Returns | |
bool | If any of the configured accessControlRules of the ACP resource matches, then the originatorhas access, and True is returned, or False otherwise. |
ACP, originator: str, requestedPermission: Permission, ty: ResourceTypes, context: str | None = 'pv', request: CSERequest | None = None) -> ACPResult:
¶
Check whether an originator has the requested permissions with this ACP.
| Parameters | |
acp:ACP | The ACP resource to check. |
originator:str | The originator to test the permissions for. |
requestedPermission | The permissions to test. |
ty:ResourceTypes | If the resource type is given then it is checked for CREATE (as an allowed child resource type), otherwise as an allowed resource type. |
context:str | None | The context to check. Default is 'pv'. |
request:CSERequest | None | Undocumented |
| Returns | |
ACPResult | If any of the configured accessControlRules of the ACP resource matches, then the originatorhas access, and True is returned, or False otherwise. Additionally, a list of accessControlAttributes combined is returned. |
Handle configuration updates.
| Parameters | |
eventEventData | The event data, containing the name of the updated configuration setting and its new value. |
CSERegistrar, cseID: str | None = None, binding: BindingType | None = BindingType.HTTP) -> tuple[ str, str] | None:
¶
Return the credentials for the Point of Access (POA) for the given CSE-ID. These credentials are used by the registrar CSE to access this hosting CSE, or by the hosting CSE to access the registrar CSE. The credentials are used in the POA attribute. Currently, only HTTP and WS bindings are supported.
| Parameters | |
registrarCSERegistrar | The CSERegistrar configuration to use. |
csestr | None | The CSE-ID to get the credentials for. |
binding:BindingType | None | The binding type to get the credentials for. Default is HTTP. |
| Returns | |
tuple[ | A tuple with the username and password or token for the given CSE-ID and binding. |
Depending on the configuration whether to use DTLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned.
This method is used for CoAP connections.
| Returns | |
ssl.SSLContext | SSL / TLD context. |
Depending on the configuration whether to use TLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned.
This method is used for HTTP connections.
| Returns | |
ssl.SSLContext | SSL / TLD context. |
Depending on the configuration whether to use TLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned.
This method is used for WebSocket connections.
| Returns | |
ssl.SSLContext | SSL / TLD context. |
str, resource: Resource, requestedPermission: Permission, ty: ResourceTypes | None = None, parentResource: Resource | None = None, request: CSERequest | None = None, resultResource: Resource | None = None) -> bool:
¶
Test whether an originator has access to a resource for the requested permission.
| Parameters | |
originator:str | The originator to check for. |
resource:Resource | The target resource of a request. |
requestedPermission | The persmission to test. |
ty:ResourceTypes | None | Mandatory for CREATE, else optional. The type of the resoure that is about to be created. |
parentResource | None | Optional, the parent resource of a target resource. |
request:CSERequest | None | Undocumented |
resultResource | None | Undocumented |
| Returns | |
bool | Boolean indicating access. |
Check whether the originator has access to the PCU resource. This should be done to check the parent PCH, but the originator would be the same as the PCU, so we can optimize this a bit.
| Parameters | |
originator:str | The request originator |
resource:PCH | PCH_PCU | Either a PCH or PCU resource |
| Returns | |
bool | Boolean indicating the result. |
Check whether the provided originator could be an AE-ID.
| Parameters | |
originator:str | The request originator. |
| Returns | |
bool | Boolean indicating the result. |
Check whether an Originator is in the provided list of allowed originators. This list may contain regex.
The hosting CSE has always access.
| Parameters | |
originator:str | The request originator. |
allowedlist[ | A list of allowed originators, which may include regex. |
| Returns | |
bool | Boolean value indicating the result. |
Validate the provided username and password against the configured HTTP basic authentication file.
| Parameters | |
username:str | The username to validate. |
password:str | The password to validate. |
| Returns | |
bool | Boolean indicating the result. |
Validate the provided token against the configured HTTP token authentication file.
| Parameters | |
token:str | The token to validate. |
| Returns | |
bool | Boolean indicating the result. |
Validate the provided username and password against the configured WebSocket basic authentication file.
| Parameters | |
username:str | The username to validate. |
password:str | The password to validate. |
| Returns | |
bool | Boolean indicating the result. |
Validate the provided token against the configured WebSocket token authentication file.
| Parameters | |
token:str | The token to validate. |
| Returns | |
bool | Boolean indicating the result. |
Dictionary to store the HTTP Basic Authentication data, mapping originators to their hashed passwords.
Dictionary to store the WebSocket Basic Authentication data, mapping originators to their hashed passwords.
bool, verifyCertificate: bool, tlsVersion: str, caCertificateFile: str, caPrivateKeyFile: str) -> ssl.SSLContext:
¶
Depending on the configuration whether to use TLS, this method creates a new SSLContext from the configured certificates and returns it. If TLS is disabled then None is returned.
| Returns | |
ssl.SSLContext | SSL / TLD context. |
Initialize the authentication information by reading the configured authentication files for HTTP and WebSocket.
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.
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.
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.
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.