BSB Developer Docs
Loading...
Searching...
No Matches
api_tokens.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <furi.h>
10#include <time.h>
11
12#define RECORD_API_TOKENS "api_tokens"
13#define API_TOKENS_LENGTH (32)
14#define API_TOKENS_SHORT_ID_LENGTH (8)
15
16typedef struct ApiTokens ApiTokens;
17
18typedef enum {
19 ApiApiTokensEntryTypeHashed,
20 ApiApiTokensEntryTypeFull,
21 ApiApiTokensEntryTypeMax,
22} ApiApiTokensEntryType;
23
27typedef struct {
28 ApiApiTokensEntryType type;
29 char* short_id;
30 char* display_id;
31 char* owner;
32 union {
33 char* full_token; // <! `TypeFull`
34 char* token_hash; // <! `TypeHashed`
35 };
36 time_t created_at;
37 time_t last_used_at;
39
40typedef void (*ApiTokenInfoCallback)(const ApiTokensEntry* entry, void* context);
41
51 ApiTokens* tokens,
52 const char* owner,
53 ApiTokenInfoCallback callback,
54 void* context);
55
63void api_tokens_list(ApiTokens* tokens, ApiTokenInfoCallback callback, void* context);
64
73bool api_tokens_revoke(ApiTokens* tokens, const char* short_id);
74
81
91bool api_tokens_validate_and_record_usage(ApiTokens* tokens, const char* full_token);
void api_tokens_list(ApiTokens *tokens, ApiTokenInfoCallback callback, void *context)
List all HTTP API access tokens.
Definition api_tokens.c:357
void api_tokens_mint(ApiTokens *tokens, const char *owner, ApiTokenInfoCallback callback, void *context)
Generates a new HTTP API access token.
Definition api_tokens.c:315
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.
Definition api_tokens.c:421
bool api_tokens_revoke(ApiTokens *tokens, const char *short_id)
Revoke one HTTP API access token.
Definition api_tokens.c:371
void api_tokens_reset_all(ApiTokens *tokens)
Revoke all HTTP API access tokens.
Definition api_tokens.c:403
Information about an HTTP API access token.
Definition api_tokens.h:27
Definition api_tokens.c:29
TIME (Simple Network Time Protocol) service API.