Iddawc
Handle the flow of OAuth2 and OpenID Connect authentication process from the client side.
Functions
Get or set struct _i_session properties

Functions

int i_set_response_type (struct _i_session *i_session, uint i_value)
 
int i_set_result (struct _i_session *i_session, uint i_value)
 
int i_set_int_parameter (struct _i_session *i_session, i_option option, uint i_value)
 
int i_set_str_parameter (struct _i_session *i_session, i_option option, const char *s_value)
 
int i_set_additional_parameter (struct _i_session *i_session, const char *s_key, const char *s_value)
 
int i_set_additional_response (struct _i_session *i_session, const char *s_key, const char *s_value)
 
int i_set_rich_authorization_request (struct _i_session *i_session, const char *type, const char *value)
 
int i_remove_rich_authorization_request (struct _i_session *i_session, const char *type)
 
char * i_get_rich_authorization_request (struct _i_session *i_session, const char *type)
 
uint i_get_response_type (struct _i_session *i_session)
 
uint i_get_result (struct _i_session *i_session)
 
uint i_get_int_parameter (struct _i_session *i_session, i_option option)
 
const char * i_get_str_parameter (struct _i_session *i_session, i_option option)
 
const char * i_get_additional_parameter (struct _i_session *i_session, const char *s_key)
 
const char * i_get_additional_response (struct _i_session *i_session, const char *s_key)
 
int i_set_parameter_list (struct _i_session *i_session,...)
 
json_t * i_export_session_json_t (struct _i_session *i_session)
 
int i_import_session_json_t (struct _i_session *i_session, json_t *j_import)
 
char * i_export_session_str (struct _i_session *i_session)
 
int i_import_session_str (struct _i_session *i_session, const char *str_import)
 

Detailed Description

Manipulates inner data of the session

Function Documentation

◆ i_set_response_type()

int i_set_response_type ( struct _i_session i_session,
uint  i_value 
)

Sets response type of a session

Parameters
i_sessiona reference to a struct _i_session *
i_valuethe response type values available are I_RESPONSE_TYPE_NONE, I_RESPONSE_TYPE_CODE, I_RESPONSE_TYPE_TOKEN, I_RESPONSE_TYPE_ID_TOKEN, I_RESPONSE_TYPE_PASSWORD, I_RESPONSE_TYPE_CLIENT_CREDENTIALS and I_RESPONSE_TYPE_REFRESH_TOKEN Values I_RESPONSE_TYPE_CODE, I_RESPONSE_TYPE_TOKEN and I_RESPONSE_TYPE_ID_TOKEN can be stacked if using hybrid flow, example: I_RESPONSE_TYPE_CODE | I_RESPONSE_TYPE_TOKEN | I_RESPONSE_TYPE_ID_TOKEN
Returns
I_OK on success, an error value on error

◆ i_set_result()

int i_set_result ( struct _i_session i_session,
uint  i_value 
)

Sets the result of a request

Parameters
i_sessiona reference to a struct _i_session *
i_valuethe result value Values available are I_OK, I_ERROR, I_ERROR_PARAM, I_ERROR_MEMORY, I_ERROR_UNAUTHORIZED orI_ERROR_SERVER
Returns
I_OK on success, an error value on error

◆ i_set_int_parameter()

int i_set_int_parameter ( struct _i_session i_session,
i_option  option,
uint  i_value 
)

Sets an unsigned integer property value

Parameters
i_sessiona reference to a struct _i_session *
optionthe option to set options availble are I_OPT_RESPONSE_TYPE, I_OPT_RESULT, I_OPT_AUTH_METHOD I_OPT_EXPIRES_IN, I_OPT_OPENID_CONFIG_STRICT
i_valueThe unsigned integer value to set
Returns
I_OK on success, an error value on error

◆ i_set_str_parameter()

int i_set_str_parameter ( struct _i_session i_session,
i_option  option,
const char *  s_value 
)

Sets a char * property value

Parameters
i_sessiona reference to a struct _i_session *
optionthe option to set options available are I_OPT_SCOPE, I_OPT_SCOPE_APPEND, I_OPT_STATE I_OPT_NONCE, I_OPT_REDIRECT_URI, I_OPT_REDIRECT_TO, I_OPT_CLIENT_ID, I_OPT_CLIENT_SECRET, I_OPT_AUTH_ENDPOINT, I_OPT_TOKEN_ENDPOINT, I_OPT_OPENID_CONFIG_ENDPOINT, I_OPT_USERINFO_ENDPOINT, I_OPT_ERROR, I_OPT_ERROR_DESCRIPTION, I_OPT_ERROR_URI, I_OPT_CODE, I_OPT_REFRESH_TOKEN, I_OPT_ACCESS_TOKEN, I_OPT_ID_TOKEN, I_OPT_GLEWLWYD_API_URL, I_OPT_GLEWLWYD_COOKIE_SESSION, I_OPT_TOKEN_TYPE, I_OPT_USERNAME, I_OPT_USER_PASSWORD, I_OPT_OPENID_CONFIG, I_OPT_ISSUER
s_valueThe char * value to set
Returns
I_OK on success, an error value on error

◆ i_set_additional_parameter()

int i_set_additional_parameter ( struct _i_session i_session,
const char *  s_key,
const char *  s_value 
)

Sets an additional parameter for auth or token requests

Parameters
i_sessiona reference to a struct _i_session *
s_keythe key to set
s_valuethe value to set
Returns
I_OK on success, an error value on error

◆ i_set_additional_response()

int i_set_additional_response ( struct _i_session i_session,
const char *  s_key,
const char *  s_value 
)

Sets an additional response value

Parameters
i_sessiona reference to a struct _i_session *
s_keythe key to set
s_valuethe value to set
Returns
I_OK on success, an error value on error

◆ i_set_rich_authorization_request()

int i_set_rich_authorization_request ( struct _i_session i_session,
const char *  type,
const char *  value 
)

Adds an authorization request object or replace it if the type already exists

Parameters
i_sessiona reference to a struct _i_session *
typethe type of the authorization request
valuethe authorization request, must be a stringified JSON object
Returns
I_OK on success, an error value on error

◆ i_remove_rich_authorization_request()

int i_remove_rich_authorization_request ( struct _i_session i_session,
const char *  type 
)

Remove an authorization request object based on the type

Parameters
i_sessiona reference to a struct _i_session *
typethe type of the authorization request
Returns
I_OK on success, an error value on error

◆ i_get_rich_authorization_request()

char* i_get_rich_authorization_request ( struct _i_session i_session,
const char *  type 
)

Returns an authorization request object based on the type

Parameters
i_sessiona reference to a struct _i_session *
typethe type of the authorization request
Returns
a char * containing a JSON stringified exported session, must be i_free'd after use, or NULL if not found

◆ i_get_response_type()

uint i_get_response_type ( struct _i_session i_session)

Returns the response type of the current session

Parameters
i_sessiona reference to a struct _i_session *
Returns
a value among the following: I_RESPONSE_TYPE_NONE, I_RESPONSE_TYPE_CODE, I_RESPONSE_TYPE_TOKEN, I_RESPONSE_TYPE_ID_TOKEN, I_RESPONSE_TYPE_PASSWORD, I_RESPONSE_TYPE_CLIENT_CREDENTIALS and I_RESPONSE_TYPE_REFRESH_TOKEN Values I_RESPONSE_TYPE_CODE, I_RESPONSE_TYPE_TOKEN and I_RESPONSE_TYPE_ID_TOKEN can be stacked if using hybrid flow, example: I_RESPONSE_TYPE_CODE | I_RESPONSE_TYPE_TOKEN | I_RESPONSE_TYPE_ID_TOKEN

◆ i_get_result()

uint i_get_result ( struct _i_session i_session)

Returns the result of the last oauth2 request

Parameters
i_sessiona reference to a struct _i_session *
Returns
I_OK on success, an error value on error

◆ i_get_int_parameter()

uint i_get_int_parameter ( struct _i_session i_session,
i_option  option 
)

Returns the integer value of an option

Parameters
i_sessiona reference to a struct _i_session *
optionthe option to get options availble are I_OPT_RESPONSE_TYPE, I_OPT_RESULT, I_OPT_AUTH_METHOD I_OPT_EXPIRES_IN, I_OPT_OPENID_CONFIG_STRICT
Returns
the option value

◆ i_get_str_parameter()

const char* i_get_str_parameter ( struct _i_session i_session,
i_option  option 
)

Returns the char * value of an option

Parameters
i_sessiona reference to a struct _i_session *
optionthe option to get options available are I_OPT_SCOPE, I_OPT_SCOPE_APPEND, I_OPT_STATE I_OPT_NONCE, I_OPT_REDIRECT_URI, I_OPT_REDIRECT_TO, I_OPT_CLIENT_ID, I_OPT_CLIENT_SECRET, I_OPT_AUTH_ENDPOINT, I_OPT_TOKEN_ENDPOINT, I_OPT_OPENID_CONFIG_ENDPOINT, I_OPT_USERINFO_ENDPOINT, I_OPT_ERROR, I_OPT_ERROR_DESCRIPTION, I_OPT_ERROR_URI, I_OPT_CODE, I_OPT_REFRESH_TOKEN, I_OPT_ACCESS_TOKEN, I_OPT_ID_TOKEN, I_OPT_GLEWLWYD_API_URL, I_OPT_GLEWLWYD_COOKIE_SESSION, I_OPT_TOKEN_TYPE, I_OPT_USERNAME, I_OPT_USER_PASSWORD, I_OPT_OPENID_CONFIG, I_OPT_ISSUER
Returns
the char * value of the option, NULL if no value set

◆ i_get_additional_parameter()

const char* i_get_additional_parameter ( struct _i_session i_session,
const char *  s_key 
)

Gets an additional parameter for auth or token requests

Parameters
i_sessiona reference to a struct _i_session *
s_keythe key to get
Returns
the value

◆ i_get_additional_response()

const char* i_get_additional_response ( struct _i_session i_session,
const char *  s_key 
)

Gets an additional response from auth or token requests

Parameters
i_sessiona reference to a struct _i_session *
s_keythe key to get
Returns
the value

◆ i_set_parameter_list()

int i_set_parameter_list ( struct _i_session i_session,
  ... 
)

Sets a list of parameters to a session

Parameters
i_sessiona reference to a struct _i_session * the list of parameters to set Uses a variable-length parameter list the syntax is the option followed by the value(s) required by the option The list must be ended by a I_OPT_NONE Example: i_set_parameter_list(i_session, I_OPT_RESPONSE_TYPE, I_RESPONSE_TYPE_CODE, I_OPT_SCOPE, "scope1", I_OPT_STATE, "abcd", I_OPT_CLIENT_ID, "client1", I_OPT_AUTH_ENDPOINT, "https://auth2.tld/auth", I_OPT_NONE);
Returns
I_OK on success, an error value on error

◆ i_export_session_json_t()

json_t* i_export_session_json_t ( struct _i_session i_session)

Exports a _i_session * into a json_t * object

Parameters
i_sessiona reference to a struct _i_session *
Returns
a json_t * object containing all data set in the session

◆ i_import_session_json_t()

int i_import_session_json_t ( struct _i_session i_session,
json_t *  j_import 
)

Imports a _i_session * from a json_t * object Imported data will overwrite existing data in i_session

Parameters
i_sessiona reference to a struct _i_session *
j_importa json_t * object in i_export_session_json_t format
Returns
I_OK on success, an error value on error

◆ i_export_session_str()

char* i_export_session_str ( struct _i_session i_session)

Exports a _i_session * into a json_t * object

Parameters
i_sessiona reference to a struct _i_session *
Returns
a char * containing a JSON stringified exported session, must be i_free'd after use

◆ i_import_session_str()

int i_import_session_str ( struct _i_session i_session,
const char *  str_import 
)

Imports a _i_session * from a json_t * object Imported data will overwrite existing data in i_session

Parameters
i_sessiona reference to a struct _i_session *
str_importa char * containing a JSON stringified session
Returns
I_OK on success, an error value on error