hook.identitylocal

class immp.hook.identitylocal.IdentityGroup(**kwargs: Any)

Bases: Model

Representation of a single identity.

instance

IdentityHook instance code.

Type:

int

name

Unique display name.

Type:

str

pwd

Hashed password, used by the user to authenticate when linking identities.

Type:

str

All links contained by this group.

Type:

.IdentityLink iterable

class Meta

Bases: object

Bases: Model

Single link between an identity and a user.

group

Containing group instance.

Type:

.IdentityGroup

network

Network identifier that the user belongs to.

Type:

str

user

User identifier as given by the plug.

Type:

str

class immp.hook.identitylocal.IdentityRole(**kwargs: Any)

Bases: Model

Assignment of a role to an identity.

group

Containing group instance.

Type:

.IdentityGroup

role

Plain role identifier.

Type:

str

class immp.hook.identitylocal.LocalIdentityHook(name, config, host, virtual=False)

Bases: Hook, AccessPredicate, IdentityProvider

Hook for managing physical users with multiple logical links across different plugs. This effectively provides self-service identities, as opposed to being provided externally.

on_load()

Perform any additional one-time setup that requires other plugs or hooks to be loaded.

async start()

Perform any underlying operations needed to ready this resource for use, such as opening connections to an external network or API.

If using an event-driven framework that yields and runs in the background, you should use a signal of some form (e.g. asyncio.Condition) to block this method until the framework is ready for use.

async get(name)

Retrieve the identity group using the given name.

Parameters:

name (str) – Existing name to query.

Returns:

Linked identity, or None if not linked.

Return type:

.IdentityGroup

async find(user)

Retrieve the identity that contains the given user, if one exists.

Parameters:

user (.User) – Existing user to query.

Returns:

Linked identity, or None if not linked.

Return type:

.IdentityGroup

async channel_access(channel, user)

Verify if a user is allowed access to a channel.

Parameters:
  • channel (.Channel) – Target channel.

  • user (.User) – User to be verified.

Returns:

True to grant access for this user to the given channel, False to deny access, or None to abstain from a decision.

Return type:

bool

async identity_from_name(name)

Look up an identity by the external provider’s username for them.

Parameters:

name (str) – External name to query.

Returns:

Matching identity from the provider, or None if not found.

Return type:

.Identity

async identity_from_user(user)

Look up an identity by a linked network user.

Parameters:

user (.User) – Plug user referenced by the identity.

Returns:

Matching identity from the provider, or None if not found.

Return type:

.Identity