imednet.auth package

Authentication helpers.

class imednet.auth.ApiKeyAuth[source]

Bases: object

Authentication strategy using API Key and Security Key.

__init__(api_key, security_key)[source]

Initialize the API Key authentication strategy.

Parameters:
  • api_key (str) – The iMednet API key.

  • security_key (str) – The iMednet security key.

Return type:

None

get_headers()[source]

Return the API key and security key headers.

Return type:

dict[str, str]

get_user_id()[source]

Return the ID of the authenticated user.

Returns:

A placeholder user ID for API key users.

Return type:

str | None

get_user_roles()[source]

Return the roles associated with the authenticated user.

Returns:

An empty list, as roles are handled by the API.

Return type:

list[str]

class imednet.auth.AuthStrategy[source]

Bases: Protocol

Protocol for authentication strategies.

Strategies must provide headers to be injected into requests.

__init__(*args, **kwargs)
get_headers()[source]

Return authentication headers.

Return type:

dict[str, str]

get_user_id()[source]

Return user identity, if available.

Return type:

Optional[str]

get_user_roles()[source]

Return resolved roles for the user, if available.

Return type:

list[str]

class imednet.auth.OIDCAuth[source]

Bases: object

Authentication strategy using OIDC token.

__init__(token)[source]

Initialize the OIDC authentication strategy.

Parameters:

token (str) – The OIDC bearer token to use for authentication.

Return type:

None

get_headers()[source]

Return the Authorization header.

Return type:

dict[str, str]

get_user_id()[source]

Extract the user identifier from the token claims.

Return type:

Optional[str]

Returns:

The user ID (sub or preferred_username) if found, otherwise None.

get_user_roles()[source]

Extract and map user roles from the token claims.

Return type:

list[str]

Returns:

A list of mapped system roles.

Submodules

imednet.auth.api_key module

API Key authentication strategy.

class imednet.auth.api_key.ApiKeyAuth[source]

Bases: object

Authentication strategy using API Key and Security Key.

__init__(api_key, security_key)[source]

Initialize the API Key authentication strategy.

Parameters:
  • api_key (str) – The iMednet API key.

  • security_key (str) – The iMednet security key.

Return type:

None

get_headers()[source]

Return the API key and security key headers.

Return type:

dict[str, str]

get_user_id()[source]

Return the ID of the authenticated user.

Returns:

A placeholder user ID for API key users.

Return type:

str | None

get_user_roles()[source]

Return the roles associated with the authenticated user.

Returns:

An empty list, as roles are handled by the API.

Return type:

list[str]

imednet.auth.oidc module

OIDC authentication strategy.

class imednet.auth.oidc.OIDCAuth[source]

Bases: object

Authentication strategy using OIDC token.

__init__(token)[source]

Initialize the OIDC authentication strategy.

Parameters:

token (str) – The OIDC bearer token to use for authentication.

Return type:

None

get_headers()[source]

Return the Authorization header.

Return type:

dict[str, str]

get_user_id()[source]

Extract the user identifier from the token claims.

Return type:

Optional[str]

Returns:

The user ID (sub or preferred_username) if found, otherwise None.

get_user_roles()[source]

Extract and map user roles from the token claims.

Return type:

list[str]

Returns:

A list of mapped system roles.

imednet.auth.strategy module

Authentication strategy protocol.

class imednet.auth.strategy.AuthStrategy[source]

Bases: Protocol

Protocol for authentication strategies.

Strategies must provide headers to be injected into requests.

__init__(*args, **kwargs)
get_headers()[source]

Return authentication headers.

Return type:

dict[str, str]

get_user_id()[source]

Return user identity, if available.

Return type:

Optional[str]

get_user_roles()[source]

Return resolved roles for the user, if available.

Return type:

list[str]