feat: add auth:read permission and ability to retrieve auth headers
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
sidebarAppHooks,
|
||||
} from './plugin-hooks';
|
||||
import { toast as appToast } from '@/stores/toast-store';
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
|
||||
// ─── Permission helpers ──────────────────────────────────────
|
||||
|
||||
@@ -128,6 +129,9 @@ export interface PluginAPI {
|
||||
info: (message: string) => void;
|
||||
warning: (message: string) => void;
|
||||
};
|
||||
auth: {
|
||||
getHeaders: () => Record<string, string>;
|
||||
};
|
||||
storage: ReturnType<typeof createPluginStorage>;
|
||||
log: ReturnType<typeof createPluginLogger>;
|
||||
admin: {
|
||||
@@ -640,6 +644,18 @@ export function createPluginAPI(plugin: InstalledPlugin): PluginAPI {
|
||||
warning: (message: string) => appToast.warning(message),
|
||||
},
|
||||
|
||||
auth: {
|
||||
getHeaders: (): Record<string, string> => {
|
||||
requirePermission(plugin, 'auth:read');
|
||||
const { client } = useAuthStore.getState();
|
||||
if (!client) return {};
|
||||
return {
|
||||
'Authorization': client.getAuthHeader(),
|
||||
'X-JMAP-Username': client.getUsername(),
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
storage: createPluginStorage(plugin.id),
|
||||
log: createPluginLogger(plugin.id),
|
||||
|
||||
|
||||
+1
-1
@@ -401,7 +401,7 @@ export const ALL_PERMISSIONS = [
|
||||
'vacation:read', 'vacation:write',
|
||||
'settings:read', 'settings:write',
|
||||
'security:read',
|
||||
'auth:observe',
|
||||
'auth:observe', 'auth:read',
|
||||
'ui:observe', 'ui:toolbar', 'ui:email-banner', 'ui:email-footer',
|
||||
'ui:composer-toolbar', 'ui:sidebar-widget', 'ui:settings-section',
|
||||
'ui:context-menu', 'ui:navigation-rail', 'ui:keyboard',
|
||||
|
||||
Reference in New Issue
Block a user