Home Assistant Unofficial Reference 2024.12.1
homeassistant.auth.auth_store.AuthStore Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass)
 
None async_activate_user (self, models.User user)
 
models.RefreshToken async_create_refresh_token (self, models.User user, str|None client_id=None, str|None client_name=None, str|None client_icon=None, str token_type=models.TOKEN_TYPE_NORMAL, timedelta access_token_expiration=ACCESS_TOKEN_EXPIRATION, float|None expire_at=None, models.Credentials|None credential=None)
 
models.User async_create_user (self, str|None name, bool|None is_owner=None, bool|None is_active=None, bool|None system_generated=None, models.Credentials|None credentials=None, list[str]|None group_ids=None, bool|None local_only=None)
 
None async_deactivate_user (self, models.User user)
 
models.Group|None async_get_group (self, str group_id)
 
list[models.Groupasync_get_groups (self)
 
models.RefreshToken|None async_get_refresh_token (self, str token_id)
 
models.RefreshToken|None async_get_refresh_token_by_token (self, str token)
 
list[models.RefreshTokenasync_get_refresh_tokens (self)
 
models.User|None async_get_user (self, str user_id)
 
list[models.Userasync_get_users (self)
 
None async_link_user (self, models.User user, models.Credentials credentials)
 
None async_load (self)
 
None async_log_refresh_token_usage (self, models.RefreshToken refresh_token, str|None remote_ip=None)
 
None async_remove_credentials (self, models.Credentials credentials)
 
None async_remove_refresh_token (self, models.RefreshToken refresh_token)
 
None async_remove_user (self, models.User user)
 
None async_set_expiry (self, models.RefreshToken refresh_token, *bool enable_expiry)
 
None async_update_user (self, models.User user, str|None name=None, bool|None is_active=None, list[str]|None group_ids=None, bool|None local_only=None)
 
None async_update_user_credentials_data (self, models.Credentials credentials, dict[str, Any] data)
 

Public Attributes

 hass
 

Private Member Functions

None _async_schedule_save (self, float delay=DEFAULT_SAVE_DELAY)
 
None _build_token_id_to_user_id (self)
 
dict[str, list[dict[str, Any]]] _data_to_save (self)
 
None _set_defaults (self)
 

Private Attributes

 _groups
 
 _loaded
 
 _perm_lookup
 
 _store
 
 _token_id_to_user_id
 
 _users
 

Detailed Description

Stores authentication info.

Any mutation to an object should happen inside the auth store.

The auth store is lazy. It won't load the data from disk until a method is
called that needs it.

Definition at line 46 of file auth_store.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.auth.auth_store.AuthStore.__init__ (   self,
HomeAssistant  hass 
)
Initialize the auth store.

Definition at line 55 of file auth_store.py.

Member Function Documentation

◆ _async_schedule_save()

None homeassistant.auth.auth_store.AuthStore._async_schedule_save (   self,
float   delay = DEFAULT_SAVE_DELAY 
)
private
Save users.

Definition at line 515 of file auth_store.py.

◆ _build_token_id_to_user_id()

None homeassistant.auth.auth_store.AuthStore._build_token_id_to_user_id (   self)
private
Build a map of token id to user id.

Definition at line 506 of file auth_store.py.

◆ _data_to_save()

dict[str, list[dict[str, Any]]] homeassistant.auth.auth_store.AuthStore._data_to_save (   self)
private
Return the data to store.

Definition at line 520 of file auth_store.py.

◆ _set_defaults()

None homeassistant.auth.auth_store.AuthStore._set_defaults (   self)
private
Set default values for auth store.

Definition at line 595 of file auth_store.py.

◆ async_activate_user()

None homeassistant.auth.auth_store.AuthStore.async_activate_user (   self,
models.User  user 
)
Activate a user.

Definition at line 177 of file auth_store.py.

◆ async_create_refresh_token()

models.RefreshToken homeassistant.auth.auth_store.AuthStore.async_create_refresh_token (   self,
models.User  user,
str | None   client_id = None,
str | None   client_name = None,
str | None   client_icon = None,
str   token_type = models.TOKEN_TYPE_NORMAL,
timedelta   access_token_expiration = ACCESS_TOKEN_EXPIRATION,
float | None   expire_at = None,
models.Credentials | None   credential = None 
)
Create a new token for a user.

Definition at line 203 of file auth_store.py.

◆ async_create_user()

models.User homeassistant.auth.auth_store.AuthStore.async_create_user (   self,
str | None  name,
bool | None   is_owner = None,
bool | None   is_active = None,
bool | None   system_generated = None,
models.Credentials | None   credentials = None,
list[str] | None   group_ids = None,
bool | None   local_only = None 
)
Create a new user.

Definition at line 83 of file auth_store.py.

◆ async_deactivate_user()

None homeassistant.auth.auth_store.AuthStore.async_deactivate_user (   self,
models.User  user 
)
Activate a user.

Definition at line 182 of file auth_store.py.

◆ async_get_group()

models.Group | None homeassistant.auth.auth_store.AuthStore.async_get_group (   self,
str  group_id 
)
Retrieve all users.

Definition at line 71 of file auth_store.py.

◆ async_get_groups()

list[models.Group] homeassistant.auth.auth_store.AuthStore.async_get_groups (   self)
Retrieve all users.

Definition at line 67 of file auth_store.py.

◆ async_get_refresh_token()

models.RefreshToken | None homeassistant.auth.auth_store.AuthStore.async_get_refresh_token (   self,
str  token_id 
)
Get refresh token by id.

Definition at line 246 of file auth_store.py.

◆ async_get_refresh_token_by_token()

models.RefreshToken | None homeassistant.auth.auth_store.AuthStore.async_get_refresh_token_by_token (   self,
str   token 
)
Get refresh token by token.

Definition at line 253 of file auth_store.py.

◆ async_get_refresh_tokens()

list[models.RefreshToken] homeassistant.auth.auth_store.AuthStore.async_get_refresh_tokens (   self)
Get all refresh tokens.

Definition at line 267 of file auth_store.py.

◆ async_get_user()

models.User | None homeassistant.auth.auth_store.AuthStore.async_get_user (   self,
str  user_id 
)
Retrieve a user by id.

Definition at line 79 of file auth_store.py.

◆ async_get_users()

list[models.User] homeassistant.auth.auth_store.AuthStore.async_get_users (   self)
Retrieve all users.

Definition at line 75 of file auth_store.py.

◆ async_link_user()

None homeassistant.auth.auth_store.AuthStore.async_link_user (   self,
models.User  user,
models.Credentials   credentials 
)
Add credentials to an existing user.

Definition at line 133 of file auth_store.py.

◆ async_load()

None homeassistant.auth.auth_store.AuthStore.async_load (   self)
Load the users.

Definition at line 311 of file auth_store.py.

◆ async_log_refresh_token_usage()

None homeassistant.auth.auth_store.AuthStore.async_log_refresh_token_usage (   self,
models.RefreshToken  refresh_token,
str | None   remote_ip = None 
)
Update refresh token last used information.

Definition at line 276 of file auth_store.py.

◆ async_remove_credentials()

None homeassistant.auth.auth_store.AuthStore.async_remove_credentials (   self,
models.Credentials  credentials 
)
Remove credentials.

Definition at line 187 of file auth_store.py.

◆ async_remove_refresh_token()

None homeassistant.auth.auth_store.AuthStore.async_remove_refresh_token (   self,
models.RefreshToken  refresh_token 
)
Remove a refresh token.

Definition at line 237 of file auth_store.py.

◆ async_remove_user()

None homeassistant.auth.auth_store.AuthStore.async_remove_user (   self,
models.User  user 
)
Remove a user.

Definition at line 141 of file auth_store.py.

◆ async_set_expiry()

None homeassistant.auth.auth_store.AuthStore.async_set_expiry (   self,
models.RefreshToken  refresh_token,
*bool   enable_expiry 
)
Enable or disable expiry of a refresh token.

Definition at line 289 of file auth_store.py.

◆ async_update_user()

None homeassistant.auth.auth_store.AuthStore.async_update_user (   self,
models.User  user,
str | None   name = None,
bool | None   is_active = None,
list[str] | None   group_ids = None,
bool | None   local_only = None 
)
Update a user.

Definition at line 149 of file auth_store.py.

◆ async_update_user_credentials_data()

None homeassistant.auth.auth_store.AuthStore.async_update_user_credentials_data (   self,
models.Credentials  credentials,
dict[str, Any]   data 
)
Update credentials data.

Definition at line 304 of file auth_store.py.

Member Data Documentation

◆ _groups

homeassistant.auth.auth_store.AuthStore._groups
private

Definition at line 500 of file auth_store.py.

◆ _loaded

homeassistant.auth.auth_store.AuthStore._loaded
private

Definition at line 58 of file auth_store.py.

◆ _perm_lookup

homeassistant.auth.auth_store.AuthStore._perm_lookup
private

Definition at line 322 of file auth_store.py.

◆ _store

homeassistant.auth.auth_store.AuthStore._store
private

Definition at line 62 of file auth_store.py.

◆ _token_id_to_user_id

homeassistant.auth.auth_store.AuthStore._token_id_to_user_id
private

Definition at line 508 of file auth_store.py.

◆ _users

homeassistant.auth.auth_store.AuthStore._users
private

Definition at line 501 of file auth_store.py.

◆ hass

homeassistant.auth.auth_store.AuthStore.hass

Definition at line 57 of file auth_store.py.


The documentation for this class was generated from the following file: