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
- domain
salobj.Domain
The DDS domain of the CSCs.
- log
logging.Logger
Create a child Logger of the provided Logger, or a new Logger if None.
- config
types.SimpleNamespace
The configuration to use. This is the same configuration as received by the Authorize CSC.
- domain
- Attributes
- response
list
ofdict
A unmarshalled JSON response from the REST server.
- authlistrequest_url
str
The Auth List Request REST endpoint constructed from the host and port as provided via the config.
- get_token_url
str
The Get Token REST endpoint constructed from the host and port as provided via the config.
- token
str
The authentication token to put in the request headers.
- lock
asyncio.Lock
A Lock to ensure that certain operations are performed atomically.
- response
Attributes Summary
Methods Summary
Authenticate against the REST server.
handle_authorize_request
(data)Send a POST with the authorize request data.
perform_periodic_task
(sleep_time)GET the approved and unprocessed authorize requests from the REST server and process them.
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 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
- data
AuthRequestData
The auth request data.
- data
- 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
- data
AuthRequestData
The data containing the authorize request as described in the corresponding xml file in ts_xml.
- data
Notes
All CSCs that can be contacted get changed, even if one or more CSCs cannot be contacted.
- async validate_request(data: AuthRequestData) → set[str]¶
Validate a requestAuthorization command by checking the input integrity.
- Parameters
- data
AuthRequestData
Command data.
- data
- Returns
- Raises
- salobj.ExpectedError
If no csc is specified.