Add optional OIDC authentication with Keycloak, Authentik, and Pocket-ID support

This commit is contained in:
2026-01-19 22:09:54 +01:00
parent 62ab6dede3
commit d64eb3db95
25 changed files with 2028 additions and 37 deletions

View File

@@ -17,3 +17,27 @@ function serverHeaders(headers) {
return headers;
}
// Auth-aware fetch wrapper that handles 401/403 responses
function authFetch(url, options) {
options = options || {};
// Ensure Accept header for API requests
if (!options.headers) {
options.headers = {};
}
if (!options.headers['Accept']) {
options.headers['Accept'] = 'application/json';
}
return fetch(url, options).then(function(response) {
// Handle authentication errors
if (response.status === 401 || response.status === 403) {
if (typeof handleAuthError === 'function') {
handleAuthError(response);
}
// Return a rejected promise to stop the chain
return Promise.reject(new Error('Authentication required'));
}
return response;
});
}