/
Logout Hook
Logout Hook
This hook will be called by the Application Layer of the Control Layer to found if the request received is a log out request. Depending on the implementation of the this hook, the log out accepted can be a GET or a POST request.
This hook functions will be called at two occasions :
- when the URL and headers of the request were received and parse by the server (state
HTTPs_AUTH_STATE_REQ_URL
). - when the request body was received and parse (state
HTTPs_AUTH_STATE_REQ_COMPLETE
).
Prototype
CPU_BOOLEAN AppGlobal_Auth_ParseLogoutHook (const HTTPs_INSTANCE *p_instance, const HTTPs_CONN *p_conn, HTTPs_AUTH_STATE state);
Arguments
p_instance
Pointer to the instance structure (read only).
p_conn
Pointer to the connection structure (read only).
state
State of the Authentication module:
HTTPs_AUTH_STATE_REQ_URL
HTTPs_AUTH_STATE_REQ_COMPLETE
Return Values
DEF_YES
, if the request is the POST with the log out information in a form.DEF_NO
, otherwise.
Required Configuration
None.
Notes / Warnings
None.
Example Template
Listing - Logout Hook Example
/* ********************************************************************************************************* * AppGlobal_Auth_ParseLogoutHook() * * Description : Parse requests received for logout URL and form data logout info. * * Argument(s) : p_instance Pointer to HTTPs instance object. * * p_conn Pointer to HTTPs connection object. * * state State of the Authentication module: * HTTPs_AUTH_STATE_REQ_URL: The url and the headers were received and parse. * HTTPs_AUTH_STATE_REQ_COMPLETE: All the request (url + headers + body) was received and parse. * * Return(s) : DEF_YES, if Logout received. * DEF_NO, otherwise. * * Caller(s) : AppGlobal_AppInst_AuthCfg. * * Note(s) : (1) This hook will be called twice for a request processed by the Authentication module: * (a) When the Start line of the request (with the url) and the headers have been * received and parse -> HTTPs_AUTH_STATE_REQ_URL state. * (b) When all the request has been completely received and parse including the body * -> HTTPs_AUTH_STATE_REQ_COMPLETE state. ********************************************************************************************************* */ CPU_BOOLEAN AppGlobal_Auth_ParseLogoutHook (const HTTPs_INSTANCE *p_instance, const HTTPs_CONN *p_conn, HTTPs_AUTH_STATE state) { CPU_BOOLEAN is_logout = DEF_NO; #if (HTTPs_CFG_FORM_EN == DEF_ENABLED) HTTPs_KEY_VAL *p_current; CPU_INT16S cmp_val; #endif switch (state) { /* --------------- REQUEST URL RECEIVED --------------- */ case HTTPs_AUTH_STATE_REQ_URL: /* Check if POST logout received. */ cmp_val = Str_Cmp(p_conn->PathPtr, LOGOUT_PAGE_CMD); if (cmp_val == 0) { is_logout = DEF_YES; } break; /* -------------- REQUEST BODY RECEIVED --------------- */ case HTTPs_AUTH_STATE_REQ_COMPLETE: #if (HTTPs_CFG_FORM_EN == DEF_ENABLED) /* Parse form fields received for logout. */ p_current = p_conn->FormDataListPtr; while (p_current != DEF_NULL) { if (p_current->DataType == HTTPs_KEY_VAL_TYPE_PAIR) { cmp_val = Str_CmpIgnoreCase_N(p_current->KeyPtr, FORM_LOGOUT_FIELD_NAME, p_current->KeyLen); if (cmp_val == 0) { is_logout = DEF_YES; break; } } p_current = p_current->NextPtr; } #endif break; default: break; } return (is_logout); }
Related content
Login Hook
Login Hook
More like this
Connection Request
Connection Request
More like this
Get Required Rights Hook
Get Required Rights Hook
More like this
Connection Close
Connection Close
More like this
Authentication module
Authentication module
More like this
Control Layer
Control Layer
More like this