Module watts_plugin

this module implements the high level view of a plugin and service.

Behaviours: gen_server.

Description

this module implements the high level view of a plugin and service. It exports the high level functions like So triggering a plugin runner for a given service and validating the result afterwards. This module is not aware of the actual run binary.

Data Types

config()

config() = #{action => parameter | request | revoke, service_id => binary(), queue => atom(), user_id => undefined | binary(), user_info => watts_userinfo:userinfo() | undefined, cred_state => binary() | undefined, params => map() | undefined, cred_id => binary() | undefined, term() => term()}

cred_entry()

cred_entry() = #{name => binary(), type => binary(), valye => binary(), term() => term()}

result()

result() = {ok, #{id => binary(), entries => [cred_entry()]}} | {ok, #{version => binary(), request_params => [any()], conf_params => [any()]}} | {oidc_login, map()} | {error, atom() | tuple() | map()}

state()

state() = #state{}

Function Index

code_change/3nothing done here.
config/1*generate a new config map, ensuring no field is missing.
exists/2checks if the credential for the given user exists.
file_lines_to_binary/2*convert a list to binary.
get_count/2return the number of credentials of a user for a specific service.
get_cred_list/1get the list of all credentials for the given user.
get_credential/2*lookup a credential for the user.
get_credential_count/2*get the number of credentials of user at service.
get_credential_list/1*get the list of credenials for a user.
get_params/1perform the 'parameter' request at the plugin for the service.
handle_call/3handle calls, the only one is to serialize storing or credential.
handle_cast/2handle casts, the only one is to stop the gen_server.
handle_info/2nothing done here.
handle_result/2*handle the results or a plugin run, including validation.
handle_result/4*handle the results or a plugin run, including validation.
init/1initialize the gen_server, doing nothing.
log_msg/2*generate a log message, if needed from the user message.
maybe_drop/2*drop the credential if allowed, else error.
remove_credential/2*delete the credential for the user.
request/4perform a request at the service for the user.
result_to_atom/1*convert the result of the plugin "ok", "error" or "oidc_login" to atom.
return/2*convert the result to the result data type.
revoke/2try to revoke the given credential for the user.
revoke_credential/2*revoke the credential for user, if found.
revoke_or_drop/2*perform the revocation or maybe drop the credential.
run_plugin/1*run a plugin.
runner_config/1*create a minimal valid runner config.
start_link/0start the gen_server process linked to the supervisor.
stop/0stop the process.
store_credential/4*store credential information.
sync_store_credential/4*serialize storing of the credential state in the database.
terminate/2nothing done here.
validate_credential_values/1*validate the credential entries returned from the plugin.
validate_credential_values/2*validate the credential entries returned from the plugin.
value_to_binary/1*convert a value to binary.
value_to_file/1*convert a value to file.

Function Details

code_change/3

code_change(OldVsn::any(), State::state(), Extra::any()) -> {ok, state()}

nothing done here

config/1 *

config(Config::map()) -> config()

generate a new config map, ensuring no field is missing.

exists/2

exists(UserInfo::watts_userinfo:info(), CredId::binary()) -> true | false

checks if the credential for the given user exists.

file_lines_to_binary/2 *

file_lines_to_binary(T::[any()], File::binary()) -> binary()

convert a list to binary

get_count/2

get_count(UserInfo::watts_userinfo:info(), ServiceId::binary()) -> {ok, non_neg_integer()}

return the number of credentials of a user for a specific service.

get_cred_list/1

get_cred_list(UserInfo::watts_userinfo:info()) -> {ok, [watts:credential()]}

get the list of all credentials for the given user.

get_credential/2 *

get_credential(UserId::binary(), CredentialId::binary()) -> {ok, watts:credential()} | {error, atom()}

lookup a credential for the user

get_credential_count/2 *

get_credential_count(UserId::binary(), ServiceId::binary()) -> {ok, integer()}

get the number of credentials of user at service

get_credential_list/1 *

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

get the list of credenials for a user

get_params/1

get_params(ServiceId::binary()) -> result()

perform the 'parameter' request at the plugin for the service.

handle_call/3

handle_call(Request::any(), From::any(), State::state()) -> {reply, any(), state()}

handle calls, the only one is to serialize storing or credential.

handle_cast/2

handle_cast(Msg::any(), State::state()) -> {noreply, state()} | {stop, normal, state()}

handle casts, the only one is to stop the gen_server.

handle_info/2

handle_info(Info::any(), State::state()) -> {noreply, state()}

nothing done here

handle_result/2 *

handle_result(X1::watts_plugin_runner:result(), Info::config()) -> result()

handle the results or a plugin run, including validation

To do

handle_result/4 *

handle_result(Result, MapOrReason, Output, Info) -> result()

handle the results or a plugin run, including validation

To do

init/1

init(X1::noparams) -> {ok, state()}

initialize the gen_server, doing nothing.

log_msg/2 *

log_msg(Map::#{log_msg => binary(), term() => term()}, UMsg::binary()) -> binary()

generate a log message, if needed from the user message

maybe_drop/2 *

maybe_drop(X1::boolean(), X2::config()) -> result()

drop the credential if allowed, else error.

remove_credential/2 *

remove_credential(UserId::binary(), CredentialId::binary()) -> result()

delete the credential for the user

request/4

request(ServiceId::binary(), UserInfo::watts_userinfo:userinfo(), Interface::binary(), Params::map()) -> result()

perform a request at the service for the user.

result_to_atom/1 *

result_to_atom(Result::atom() | binary()) -> atom()

convert the result of the plugin "ok", "error" or "oidc_login" to atom.

return/2 *

return(X1::result | oidc_login | error, Result::map() | atom() | tuple()) -> result()

convert the result to the result data type.

revoke/2

revoke(CredentialId::binary(), UserInfo::watts_userinfo:info()) -> result()

try to revoke the given credential for the user

revoke_credential/2 *

revoke_credential(MaybeCredential, UserInfo::watts_userinfo:info()) -> result()

revoke the credential for user, if found.

revoke_or_drop/2 *

revoke_or_drop(X1::boolean(), Config::config()) -> result()

perform the revocation or maybe drop the credential.

run_plugin/1 *

run_plugin(Config::config()) -> watts_plugin_runner:result()

run a plugin

runner_config/1 *

runner_config(Config::map()) -> watts_plugin_runner:config()

create a minimal valid runner config

start_link/0

start_link() -> {ok, pid()}

start the gen_server process linked to the supervisor

stop/0

stop() -> ok

stop the process

store_credential/4 *

store_credential(UserId::binary(), ServiceId::binary(), Interface::binary(), CredentialState::binary()) -> {ok, binary()} | {error, atom()}

store credential information. The only information stored are:

sync_store_credential/4 *

sync_store_credential(UserId::binary(), ServiceId::binary(), Interface::binary(), CredState::binary()) -> {ok, binary()} | {error, Reason::atom()}

serialize storing of the credential state in the database.

terminate/2

terminate(Reason::any(), State::state()) -> ok

nothing done here

validate_credential_values/1 *

validate_credential_values(Credential::[map()]) -> [cred_entry()]

validate the credential entries returned from the plugin

validate_credential_values/2 *

validate_credential_values(T::[map()], ValidatedCredential::[cred_entry()]) -> [cred_entry()]

validate the credential entries returned from the plugin

value_to_binary/1 *

value_to_binary(Val::any()) -> binary()

convert a value to binary

value_to_file/1 *

value_to_file(Val::any()) -> binary()

convert a value to file


Generated by EDoc