hook.identity#

class immp.hook.identity.Identity(name, provider=None, links=(), roles=(), profile=None)#

Bases: object

Basic representation of an external identity.

name#

Common name used across any linked platforms.

Type:

str

provider#

Service hook where the identity information was acquired from.

Type:

.IdentityProvider

Physical platform users assigned to this identity.

Type:

.User list

roles#

Optional set of role names, if applicable to the backend.

Type:

str list

profile#

URL to the identity profile page.

Type:

str

async classmethod gather(*tasks)#

Helper for fetching users from plugs, filtering out calls with no matches:

>>> await Identity.gather(plug1.user_from_id(id1), plug2.user_from_id(id2))
[<Plug1User: '123' 'User'>]
Parameters:

tasks (coroutine list) – Non-awaited coroutines or tasks.

Returns:

Gathered results of those tasks.

Return type:

.User list

class immp.hook.identity.IdentityProvider#

Bases: object

Interface for hooks to provide identity information from a backing source.

provider_name#

Readable name of the underlying service, used when displaying info about this provider.

Type:

str

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

class immp.hook.identity.WhoIsHook(name, config, host, virtual=False)#

Bases: Hook

Hook to provide generic lookup of user profiles across one or more identity providers.