feat: add garage.toml support (#30)

This commit is contained in:
Noste
2026-04-24 11:27:43 +02:00
committed by GitHub
parent a5f064761b
commit f1eeca60bf
19 changed files with 907 additions and 131 deletions
+32 -1
View File
@@ -16,6 +16,7 @@ interface AuthStore extends AuthState {
// Async actions
initialize: () => Promise<void>;
loginAdmin: (username: string, password: string) => Promise<void>;
loginToken: (token: string) => Promise<void>;
loginOIDC: () => void;
logout: () => Promise<void>;
}
@@ -45,7 +46,7 @@ export const useAuthStore = create<AuthStore>()(
set({ config });
// If no auth is enabled, mark as authenticated immediately
if (!config.admin.enabled && !config.oidc.enabled) {
if (!config.admin.enabled && !config.oidc.enabled && !config.token.enabled) {
set({
isAuthenticated: true,
isLoading: false,
@@ -113,6 +114,36 @@ export const useAuthStore = create<AuthStore>()(
}
},
loginToken: async (token) => {
try {
set({ isLoading: true, error: null });
const response = await authApi.loginToken(token);
const { token: sessionToken, user } = response.data;
localStorage.setItem('auth-token', sessionToken);
set({
user,
isAuthenticated: true,
isLoading: false,
error: null,
});
} catch (error) {
const errorMessage =
(error as { response?: { data?: { error?: { message?: string } } } })
.response?.data?.error?.message ||
(error instanceof Error ? error.message : 'Login failed');
set({
error: errorMessage,
isLoading: false,
isAuthenticated: false,
user: null,
});
throw error;
}
},
loginOIDC: () => {
// Redirect to OIDC login endpoint
window.location.href = '/auth/oidc/login';