heimdall.auth package

Submodules

heimdall.auth.authorizer module

exception heimdall.auth.authorizer.AuthorizationError(status_code, message)[source]

Bases: Exception

class heimdall.auth.authorizer.Authorizer(pep: PolicyEnforcementProvider, client: HeimdallClient, user_agent: str)[source]

Bases: object

authorize(token: str, correlation_id: str) AuthorizationResponse[source]

Authorizes an access token using the Heimdall client’s authorization API.

Parameters:
  • token (str) – The access token to authorize.

  • correlation_id (str) – The correlation ID for the authorization request.

Returns:

An AuthorizationResponse object containing the result of the authorization request.

Return type:

AuthorizationResponse

authorize_atom(token: str, atom_id: str, variable_values: Dict[str, str] | None = None, correlation_id: str = '')[source]

Authorizes an access token for a specific atom using the Heimdall client’s authorization API.

Parameters:
  • token (str) – The access token to authorize.

  • atom_id (str) – The ID of the atom to authorize the token for.

  • variable_values (Dict[str, str]) – A map of variable names to values used to resolve the atom’s inputs.

  • correlation_id (str) – The correlation ID for the authorization request.

Returns:

An AuthorizationResponse object containing the result of the authorization request.

Return type:

AuthorizationResponse

authorize_batch(token: str, batch: Dict[str, Tuple[str, Dict[str, str]]], correlation_id: str = '')[source]

Authorizes a token for a batch of atoms and returns the AuthorizationResponseBatch.

Parameters:
  • token (str) – The token to authorize.

  • batch (Dict[str, Tuple[str, Dict[str, str], str]]) – A map of atom IDs to tuples of atom ID, variable values, and correlation ID.

  • correlation_id (str) – The correlation ID to include in the authorization request.

Returns:

The AuthorizationResponseBatch for the given token and batch of atoms.

Return type:

AuthorizationResponseBatch

heimdall.auth.policy_enforcement_provider module

class heimdall.auth.policy_enforcement_provider.PolicyEnforcementProvider(version: str, id: str, name: str, description: str, atoms: List[AuthorizationAtom] = None)[source]

Bases: BaseModel

add_atom(atom: AuthorizationAtom)[source]

Adds an authorization atom to this policy enforcement provider.

Parameters:

atom (AuthorizationAtom) – The authorization atom to add.

authorization_atoms: List[AuthorizationAtom]
description: str
export(file_path: str)[source]

Exports this policy enforcement provider to a file.

Parameters:

file (str) – The path to the file to write to.

find_variables(strings: List[str]) List[str][source]

Finds variables in the given list of strings and returns them in a list.

Parameters:

strings (List[str]) – The list of strings in which to find variables.

Returns:

The list of variables found in the strings.

Return type:

List[str]

get_atom(atom_id: str, variables: dict) AuthorizationAtom | None[source]

Gets an authorization atom from this policy enforcement provider.

Parameters:
  • atom_id (str) – The ID of the authorization atom to get.

  • variables (Dict[str, str], optional) – The map of variable names to values used to resolve the atom’s inputs, defaults to None.

Returns:

The authorization atom with the specified ID and variable values, or None if no such atom exists or if any required variable values are missing.

Return type:

AuthorizationAtom or None

id: str
name: str
replace_variables(variables: dict, strings: List[str]) List[str][source]

Replaces variables in the given list of strings with their corresponding values from the given map of variables.

Parameters:
  • variables (Dict[str, str]) – The map of variables to replace in the strings.

  • strings (List[str]) – The list of strings in which to replace the variables.

Returns:

The list of strings with variables replaced by their corresponding values from the map of variables.

Return type:

List[str]

version: str

Module contents