Module watts_rsp

this module implements the RSP interface of WaTTS.

Description

this module implements the RSP interface of WaTTS. This includes checking if an RSP is configured, validating the passed jwts and sending users back to the RSPs.

Data Types

request_type()

request_type() = rsp_ui_login | rsp_no_ui_login | rsp_ui_no_login | rsp_no_ui_no_login

rsp()

rsp() = #watts_rsp{id = undefined | binary(), key_location = undefined | binary(), key_pid = undefined | pid(), perform_login = boolean(), show_ui = boolean(), base_url = undefined | binary(), session = session()}

session()

session() = #watts_rsp_session{referer = undefined | binary(), success_url = undefined | binary(), failed_url = undefined | binary(), iss = undefined | binary(), sub = undefined | binary(), service_id = undefined | binary(), params = undefined | map(), provider = undefined | binary()}

Function Index

ensure_map/1*convert a list into a map, if needed.
error_return_url/3*return back on error, either to the failed url, if valid, or referer.
exists/1check if an rsp exists.
extract_urls/1*get the urls from the session (passed in via the jwt).
failed_or_referer/3*use the passed failure url, if valid, else referer url.
get_id/1return the id of an rsp, given its configuration.
get_info/1get the rsp config from the list of configs, if it exists.
get_iss_sub/1return the iss/sub of an rsp, given its configuration (session).
get_list/0get the list of all configured RSPs.
get_provider/1return the provider id of an rsp, given its configuration (session).
get_return_urls/1return the return urls of an rsp, given its configuration (session).
get_rsp_from_jwt_map/1*get the rsp configuration from the jwt map.
get_service_data/1return the service id and params from the rsp configuration (session).
has_valid_return/1*check if the rsp has valid return urls (also session).
is_valid_url/2*check if a url is valid (needs to start with http(s) and have the configured base.
jwt_get_failed_url/1*get the failed url from the jwt.
jwt_get_params/1*the the function params from the jwt.
jwt_get_provider/1*get the provider from the jwt.
jwt_get_service_id/1*get the service id from the jwt.
jwt_get_subject/1*get the subject from the jwt.
jwt_get_success_url/1*get the success url from the jwt.
maybe_return_jwt/5*return the jwt if service and provider exist, else error.
new/1create a new rsp configuration from the data in the config file.
provider_exists/1*check if the provider exists, if not used return true.
request_type/1return the request type, an atom, of the rsp, if valid.
request_type/2*return the request type, an atom, of the rsp, if valid.
session_return_urls/1*return the success and failure url from a rsp session.
session_type/1return the session type of the rsp.
starts_with_base/2*check if the url starts with the configured base url.
update_rsp_on_success/2*update the rsp with a new session containing the claims from the jwt.
validate_jwt/1*validate the jwt with the keys of the rsp, if it exists.
validate_jwt_content/3*validate the result of the parsed jwt, or the error.
validate_jwt_get_rsp/2validate the passed jwt data with the referer.

Function Details

ensure_map/1 *

ensure_map(Map::map() | list()) -> map()

convert a list into a map, if needed.

error_return_url/3 *

error_return_url(Watts_rsp::rsp(), X2::map(), Referer::binary()) -> binary()

return back on error, either to the failed url, if valid, or referer

exists/1

exists(RspId::binary()) -> boolean()

check if an rsp exists

extract_urls/1 *

extract_urls(Watts_rsp_session::session()) -> [binary()]

get the urls from the session (passed in via the jwt)

failed_or_referer/3 *

failed_or_referer(X1::boolean(), FailedUrl::binary(), Referer::binary()) -> binary()

use the passed failure url, if valid, else referer url

get_id/1

get_id(Watts_rsp::rsp()) -> {ok, binary()}

return the id of an rsp, given its configuration

get_info/1

get_info(Id::binary()) -> rsp()

get the rsp config from the list of configs, if it exists

get_iss_sub/1

get_iss_sub(Watts_rsp::rsp()) -> {binary(), binary()}

return the iss/sub of an rsp, given its configuration (session)

get_list/0

get_list() -> {ok, [rsp()]}

get the list of all configured RSPs

get_provider/1

get_provider(Watts_rsp::rsp()) -> binary() | undefined

return the provider id of an rsp, given its configuration (session)

get_return_urls/1

get_return_urls(Watts_rsp::rsp()) -> {binary(), binary()}

return the return urls of an rsp, given its configuration (session)

get_rsp_from_jwt_map/1 *

get_rsp_from_jwt_map(X1::map() | any()) -> rsp()

get the rsp configuration from the jwt map

get_service_data/1

get_service_data(Watts_rsp::rsp()) -> {binary(), map()}

return the service id and params from the rsp configuration (session).

has_valid_return/1 *

has_valid_return(Watts_rsp::rsp()) -> boolean()

check if the rsp has valid return urls (also session).

is_valid_url/2 *

is_valid_url(Url::binary(), Base::binary()) -> boolean()

check if a url is valid (needs to start with http(s) and have the configured base.

jwt_get_failed_url/1 *

jwt_get_failed_url(Claims::map()) -> binary() | undefined

get the failed url from the jwt

jwt_get_params/1 *

jwt_get_params(Claims::map()) -> map()

the the function params from the jwt

jwt_get_provider/1 *

jwt_get_provider(Claims::map()) -> binary() | undefined

get the provider from the jwt

jwt_get_service_id/1 *

jwt_get_service_id(Claims::map()) -> binary()

get the service id from the jwt

jwt_get_subject/1 *

jwt_get_subject(Claims::map()) -> binary() | undefined

get the subject from the jwt

jwt_get_success_url/1 *

jwt_get_success_url(Claims::map()) -> binary() | undefined

get the success url from the jwt

maybe_return_jwt/5 *

maybe_return_jwt(X1::boolean(), X2::boolean(), Jwt::map(), Rsp::rsp(), JwtMap::map()) -> {ok, map(), rsp()} | {error, Reason::any(), rsp(), map()}

return the jwt if service and provider exist, else error

new/1

new(Map::map()) -> {ok, rsp()}

create a new rsp configuration from the data in the config file. It also starts a watts_rsp_keys process and referces it.

provider_exists/1 *

provider_exists(Id::any()) -> boolean()

check if the provider exists, if not used return true

request_type/1

request_type(Rsp::rsp()) -> request_type() | {error, Reason::atom()}

return the request type, an atom, of the rsp, if valid. Ensure the request has valid return urls

request_type/2 *

request_type(X1::boolean(), Watts_rsp::rsp()) -> rsp_ui_login | rsp_no_ui_login | rsp_ui_no_login | rsp_no_ui_no_login | {error, Reason::atom()}

return the request type, an atom, of the rsp, if valid.

session_return_urls/1 *

session_return_urls(Watts_rsp_session::session()) -> {binary(), binary()}

return the success and failure url from a rsp session.

session_type/1

session_type(Watts_rsp::rsp()) -> watts_session:type()

return the session type of the rsp. this is basically a tuple indicating that it is an rsp session and wether the ui should be shown and if the login should be performed or not.

starts_with_base/2 *

starts_with_base(Url::binary(), Base::binary()) -> boolean()

check if the url starts with the configured base url

update_rsp_on_success/2 *

update_rsp_on_success(X1::{ok, map(), rsp()} | {error, any(), rsp(), map()}, Referer::binary()) -> {ok, rsp()} | {error, {bad_jwt, any()}, binary()}

update the rsp with a new session containing the claims from the jwt

validate_jwt/1 *

validate_jwt(Jwt::binary()) -> {ok, map(), rsp()} | {error, Reason::any(), rsp(), map()}

validate the jwt with the keys of the rsp, if it exists. A non existing rsp will result in an empty list of keys.

validate_jwt_content/3 *

validate_jwt_content(X1::{ok, map()} | {error, any()}, Rsp::rsp(), JwtMap::map()) -> {ok, map(), rsp()} | {error, Reason::any(), rsp(), map()}

validate the result of the parsed jwt, or the error. Ensure the content of the jwt is valid and the service and the provider do exist.

validate_jwt_get_rsp/2

validate_jwt_get_rsp(JwtData::binary(), Referer::binary()) -> {ok, rsp()} | {error, Reason::any(), Url::binary()}

validate the passed jwt data with the referer.


Generated by EDoc