RestAuthorizeHandler

class lsst.ts.authorize.RestAuthorizeHandler(domain: Domain, callback: Callable[[int, str], Awaitable[None]], log: logging.Logger | None = None, config: types.SimpleNamespace | None = None)

Bases: BaseAuthorizeHandler

Authorize handler that uses REST calls to communicate with a REST server.

Forward any incoming authorization requests to the REST server so an operator can approve or deny the request. Periodically poll the REST server for approved but unprocessed authorization requests so the corresponding CSCs may be informed.

Parameters
domainsalobj.Domain

The DDS domain of the CSCs.

loglogging.Logger

Create a child Logger of the provided Logger, or a new Logger if None.

configtypes.SimpleNamespace

The configuration to use. This is the same configuration as received by the Authorize CSC.

Attributes
responselist of dict

A unmarshalled JSON response from the REST server.

authlistrequest_urlstr

The Auth List Request REST endpoint constructed from the host and port as provided via the config.

get_token_urlstr

The Get Token REST endpoint constructed from the host and port as provided via the config.

tokenstr

The authentication token to put in the request headers.

lockasyncio.Lock

A Lock to ensure that certain operations are performed atomically.

Attributes Summary

client_session

Methods Summary

authenticate()

Authenticate against the REST server.

close_client_session()

create_client_session()

handle_authorize_request(data)

Send a POST with the authorize request data.

perform_periodic_task(sleep_time)

process_approved_and_unprocessed_auth_requests()

GET the approved and unprocessed authorize requests from the REST server and process them.

process_authorize_request(data)

Process an authorize request.

start(sleep_time)

stop()

validate_request(data)

Validate a requestAuthorization command by checking the input integrity.

Attributes Documentation

client_session

Methods Documentation

async authenticate() None

Authenticate against the REST server.

Raises
RuntimeError

In case of an unexpected response.

async close_client_session() None
async create_client_session() None
async handle_authorize_request(data: AuthRequestData) None

Send a POST with the authorize request data.

The reply received from the REST server is not used and is stored for testing purposes.

Parameters
dataAuthRequestData

The auth request data.

async perform_periodic_task(sleep_time: float) None
async process_approved_and_unprocessed_auth_requests() None

GET the approved and unprocessed authorize requests from the REST server and process them.

These are authorize requests that have been approved by an operator and that have not been processed by this CSC yet.

async process_authorize_request(data: AuthRequestData) tuple[dict[str, str], set[str]]

Process an authorize request. Contact each CSC in the request and send the setAuthList command.

Parameters
dataAuthRequestData

The data containing the authorize request as described in the corresponding xml file in ts_xml.

Notes

All CSCs that can be contacted get changed, even if one or more CSCs cannot be contacted.

async start(sleep_time: float) None
async stop() None
async validate_request(data: AuthRequestData) set[str]

Validate a requestAuthorization command by checking the input integrity.

Parameters
dataAuthRequestData

Command data.

Returns
cscs_to_commandset of str

List of strings with name:index of the CSCs to send setAuthList commands to.

Raises
salobj.ExpectedError

If no csc is specified.