esgf_core_utils.models.auth

Models relating to Authorisation for the ESGF Next Gen Core Architecture.

Attributes

logger

Role

Exceptions

AuthorizationException

Raised when the caller is not authorised to perform an operation.

MissingPermissionException

Raised when a user does not possess a required permission.

Classes

RequesterData

Model describing Requests Data for the Auth component of a Kafka

Permission

Model describing Permission auth info of a ESGF publisher.

PermissionStore

Model describing Permission store of a ESGF publisher.

Nodes

Model describing Nodes auth info of a ESGF publisher.

Projects

Model describing Project auth info of a ESGF publisher.

Authorizer

Model describing Authentication information of a ESGF publisher.

Package Contents

exception esgf_core_utils.models.auth.AuthorizationException

Bases: RFC9457Exception

Raised when the caller is not authorised to perform an operation.

status_code: ClassVar[int] = 403
type: ClassVar[str] = 'https://esgf.io/publication/errors/missing-permission'
title: ClassVar[str] = 'You do not have permission'
property detail: str

Details of exception.

exception esgf_core_utils.models.auth.MissingPermissionException

Bases: Exception

Raised when a user does not possess a required permission.

type: str
target: str
role: str = ''
__str__() → str

Exception message.

class esgf_core_utils.models.auth.RequesterData(/, **data: Any)

Bases: pydantic.BaseModel

Model describing Requests Data for the Auth component of a Kafka message in more detail.

client_id: str
iss: str
sub: str
esgf_core_utils.models.auth.logger
esgf_core_utils.models.auth.Role
class esgf_core_utils.models.auth.Permission(/, **data: Any)

Bases: pydantic.BaseModel

Model describing Permission auth info of a ESGF publisher.

id: str
roles: set[Role]
class esgf_core_utils.models.auth.PermissionStore(/, **data: Any)

Bases: pydantic.BaseModel

Model describing Permission store of a ESGF publisher.

permissions: dict[str, Permission]
add(permission: Permission | dict[str, Any]) → None

Add a new project or update roles if project already exists.

Args:

project (Permission | dict): project to be added

class esgf_core_utils.models.auth.Nodes(/, **data: Any)

Bases: PermissionStore

Model describing Nodes auth info of a ESGF publisher.

authorize_href(asset_href: str, role: Role) → None

Authorize an assets href

Args:

asset_href (str): href of asset to authorized role (Role): role to be checked

Raises:

MissingPermissionException: Permissions is missing

authorize(assets: dict[str, Any], role: Role) → None

Check for appropriate authorisation.

Args:

assets (dict): item to be authorised role (Role): required role for auhroisation

Raises:

MissingPermissionException: Raised if either node or role permission is missing

class esgf_core_utils.models.auth.Projects(/, **data: Any)

Bases: PermissionStore

Model describing Project auth info of a ESGF publisher.

authorize(project: str, role: Role) → None

Check for appropriate authorisation.

Args:

item (Item): item to be authorised role (Role): required role for auhroisation

Raises:

MissingPermissionException: Raised if either node or role permission is missing

class esgf_core_utils.models.auth.Authorizer(/, **data: Any)

Bases: pydantic.BaseModel

Model describing Authentication information of a ESGF publisher.

requester_data: esgf_core_utils.models.kafka.events.RequesterData
nodes: Nodes
projects: Projects
regex: str
authorize(collection_id: str, item: stac_pydantic.item.Item | stac_fastapi.extensions.transaction.request.PartialItem, role: Role, request_id: str, event_id: str) → None

Check for appropriate authorisation.

Args:

collection_id: collection id of request item (Item): item to be authorised role (Role): required role for auhroisation

Raises:

AuthorizationException: Raised if either node or role permission is missing

add(entitlements: list[str]) → None

add entitlements to Authorizer.

Args:

entitlements (list[str]): list of entitlements to be added