BSB Developer Docs
Loading...
Searching...
No Matches
api_tokens.h File Reference

Manages HTTP access tokens. More...

#include <furi.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  ApiTokensEntry
 Information about an HTTP API access token. More...
 

Macros

#define RECORD_API_TOKENS   "api_tokens"
 
#define API_TOKENS_LENGTH   (32)
 
#define API_TOKENS_SHORT_ID_LENGTH   (8)
 

Typedefs

typedef struct ApiTokens ApiTokens
 
typedef void(* ApiTokenInfoCallback) (const ApiTokensEntry *entry, void *context)
 

Enumerations

enum  ApiApiTokensEntryType { ApiApiTokensEntryTypeHashed , ApiApiTokensEntryTypeFull , ApiApiTokensEntryTypeMax }
 

Functions

void api_tokens_mint (ApiTokens *tokens, const char *owner, ApiTokenInfoCallback callback, void *context)
 Generates a new HTTP API access token.
 
void api_tokens_list (ApiTokens *tokens, ApiTokenInfoCallback callback, void *context)
 List all HTTP API access tokens.
 
bool api_tokens_revoke (ApiTokens *tokens, const char *short_id)
 Revoke one HTTP API access token.
 
void api_tokens_reset_all (ApiTokens *tokens)
 Revoke all HTTP API access tokens.
 
bool api_tokens_validate_and_record_usage (ApiTokens *tokens, const char *full_token)
 Check that the provided access token is valid, and update its last_used_at property.
 

Detailed Description

Manages HTTP access tokens.

Function Documentation

◆ api_tokens_list()

void api_tokens_list ( ApiTokens * tokens,
ApiTokenInfoCallback callback,
void * context )

List all HTTP API access tokens.

Parameters
[in]tokensApiTokens service
[in]callbackCallback, called for each listed token
[in]contextCustom context to pass to callback verbatim

◆ api_tokens_mint()

void api_tokens_mint ( ApiTokens * tokens,
const char * owner,
ApiTokenInfoCallback callback,
void * context )

Generates a new HTTP API access token.

Parameters
[in,out]tokensApiTokens service
[in]ownerHuman-readable name for the token
[in]callbackCallback with info about the generated token
[in]contextCustom context to pass to callback verbatim

◆ api_tokens_reset_all()

void api_tokens_reset_all ( ApiTokens * tokens)

Revoke all HTTP API access tokens.

Parameters
[in,out]tokensApiTokens service

◆ api_tokens_revoke()

bool api_tokens_revoke ( ApiTokens * tokens,
const char * short_id )

Revoke one HTTP API access token.

Parameters
[in,out]tokensApiTokens service
[in]short_idToken short ID
Returns
false if requested token was not found

◆ api_tokens_validate_and_record_usage()

bool api_tokens_validate_and_record_usage ( ApiTokens * tokens,
const char * full_token )

Check that the provided access token is valid, and update its last_used_at property.

Parameters
[in,out]tokensApiTokens service
[in]full_tokenFull access token
Returns
true if access should be granted