library/src/network/httpd/BP-HTTPdSessions.cc
// Checks to see if an xsrf token matches one generated
Checks to see if an xsrf token matches one generated
Checks to see if an xsrf token matches one generated
P_BP_HTTPD_SESSION_XSRF_TOKEN BP_HTTPdSessionXSRFTokenLookup
(
		P_BP_HTTPD_USER_SESSION user_session,
		char                   *xsrf_token
)
{
	if(!user_session)
		return NULL;
	if(!xsrf_token)
		return NULL;
	if(!BP_StringIsUUID(xsrf_token))
		return NULL;
	char *new_xsrf_token_lookup_path[10];
	BP_ZERO_STACK(new_xsrf_token_lookup_path);
	new_xsrf_token_lookup_path[0] = "tokens";
	new_xsrf_token_lookup_path[1] = xsrf_token;
	P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = BP_HashRegLookupTableEntryByPath(user_session->xsrf_reg, (char **) new_xsrf_token_lookup_path);
	if(!lookup_entry)
		return NULL;
	if(!lookup_entry->data)
		return NULL;
	return (P_BP_HTTPD_SESSION_XSRF_TOKEN) lookup_entry->data;
}
P_BP_HTTPD_SESSION_XSRF_TOKEN BP_HTTPdSessionXSRFTokenLookup ( P_BP_HTTPD_USER_SESSION user_session , char * xsrf_token ) { if ( ! user_session ) return NULL ; if ( ! xsrf_token ) return NULL ; if ( ! BP_StringIsUUID ( xsrf_token ) ) return NULL ; char * new_xsrf_token_lookup_path [ 10 ] ; BP_ZERO_STACK ( new_xsrf_token_lookup_path ) ; new_xsrf_token_lookup_path [ 0 ] = " " ; new_xsrf_token_lookup_path [ 1 ] = xsrf_token ; P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = BP_HashRegLookupTableEntryByPath ( user_session -> xsrf_reg , ( char * * ) new_xsrf_token_lookup_path ) ; if ( ! lookup_entry ) return NULL ; if ( ! lookup_entry -> data ) return NULL ; return ( P_BP_HTTPD_SESSION_XSRF_TOKEN ) lookup_entry -> data ; }
Checks to see if an xsrf token matches one generated
Checks to see if an xsrf token matches one generated
// basic null checks // ensure the token is a uuid // xsrf_tokens // set path for lookup // attempt to lookup the entry // return the looked up data if we got a lookup