mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-11-06 02:25:24 +00:00
feat: limit api keys to actions when they are made
This commit is contained in:
1 parent
03029cd372
commit
2e79bf9d0d
8 files changed
+47
-5
No files matched your search
@@ -87,6 +87,8 @@ export interface ApiKey {
|
||||
expiresAt: string | null;
|
||||
lastUsedAt: string | null;
|
||||
isActive: boolean;
|
||||
/** Null for full access. */
|
||||
scopes?: string[] | null;
|
||||
}
|
||||
|
||||
export interface CreatedApiKey extends ApiKey {
|
||||
@@ -97,12 +99,14 @@ export async function createApiKey(
|
||||
name: string,
|
||||
userId: string,
|
||||
expiresAt?: string,
|
||||
scopes?: string[] | null,
|
||||
): Promise<CreatedApiKey> {
|
||||
try {
|
||||
const response = await authApi.post("/users/api-keys", {
|
||||
name,
|
||||
userId,
|
||||
expiresAt: expiresAt ?? null,
|
||||
scopes: scopes?.length ? scopes : null,
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user