Module watts_persistent

This module defines the needed callbacks for WaTTS persistent storage.

This module defines the watts_persistent behaviour.
Required callback functions: initialize/0, credential_add/5, credential_get_list/1, credential_get_count/2, credential_get/1, credential_remove/2, is_ready/0.

Description

This module defines the needed callbacks for WaTTS persistent storage. Any module implementing these can be used to store credentials. So extending the supported databases woule mean to implement a new watts_persistent_xxx module. Also the config/schema/watts.schema needs to be adjusted to supporte the new database and its config.

Function Index

credential_delete/2delete the credential with the Id.
credential_fetch/2get the credential with the Id for the given User.
credential_fetch_list/1fetch the list of all credentials for a user.
credential_service_count/2get the number of credentials of the user at the service.
credential_store/5storing a credential, this is done by calling the configured database and credential_add there.
ensure_credential_of_user/2*this function ensures that credentials are only returned to their owner.
init/0this gets called during initialization.
is_ready/0check if the configured database is ready.
mod/0*get the configured database module.

Function Details

credential_delete/2

credential_delete(UserId::binary(), CredentialId::binary()) -> ok | {error, Reason::atom()}

delete the credential with the Id. using the configured database.

credential_fetch/2

credential_fetch(CredId::binary(), UserId::binary()) -> {ok, watts:credential()} | {error, Reason::atom()}

get the credential with the Id for the given User. using the configured database.

credential_fetch_list/1

credential_fetch_list(UserId::binary()) -> {ok, [watts:credential()]}

fetch the list of all credentials for a user. using the configured database.

credential_service_count/2

credential_service_count(UserId::binary(), ServiceId::binary()) -> {ok, pos_integer()}

get the number of credentials of the user at the service. using the configured database.

credential_store/5

credential_store(UserId::binary(), ServiceId::binary(), Interface::binary(), CredState::any(), AllowNonUniqueStates::boolean()) -> {ok, CredentialId::binary()} | {error, Reason::atom()}

storing a credential, this is done by calling the configured database and credential_add there.

ensure_credential_of_user/2 *

ensure_credential_of_user(Result::{ok, watts:credential()} | {error, Reason::atom()}, UserId::binary()) -> {ok, watts:credential()} | {error, Reason::atom()}

this function ensures that credentials are only returned to their owner.

init/0

init() -> ok | {error, Reason::atom()}

this gets called during initialization. The function calls the initalize function of the configured database.

is_ready/0

is_ready() -> true | {false, Reason::any()}

check if the configured database is ready.

mod/0 *

mod() -> atom()

get the configured database module.


Generated by EDoc