Fix provider access

This commit is contained in:
Aaron Dalton 2024-02-04 22:02:18 -05:00
parent 13140886a9
commit e2a1780a81
3 changed files with 3 additions and 8 deletions

View File

@ -2,12 +2,12 @@ import ProxyAuthProvider from "./proxy";
import NullAuthProvider from "./null"; import NullAuthProvider from "./null";
const AuthProviders = { const AuthProviders = {
NullAuthProvider, null: NullAuthProvider,
ProxyAuthProvider, proxy: ProxyAuthProvider,
}; };
function getProviderByKey(key) { function getProviderByKey(key) {
return AuthProviders.find((provider) => provider.key === key) ?? NullAuthProvider; return AuthProviders[key] || NullAuthProvider;
} }
function authAllow({ user, groups }, item) { function authAllow({ user, groups }, item) {

View File

@ -1,5 +1,4 @@
const NullPermissions = { user: null, groups: [] }; const NullPermissions = { user: null, groups: [] };
const NullAuthKey = "none";
function createNullAuth() { function createNullAuth() {
return { return {
@ -15,7 +14,6 @@ async function fetchNullAuth([key]) {
} }
const NullAuthProvider = { const NullAuthProvider = {
key: NullAuthKey,
create: createNullAuth, create: createNullAuth,
fetch: fetchNullAuth, fetch: fetchNullAuth,
}; };

View File

@ -1,7 +1,5 @@
// 'proxy' auth provider is meant to be used by a reverse proxy that injects permission headers into the origin // 'proxy' auth provider is meant to be used by a reverse proxy that injects permission headers into the origin
// request. In this case we are relying on our proxy to authenitcate our users and validate. // request. In this case we are relying on our proxy to authenitcate our users and validate.
const ProxyAuthKey = "proxy";
function getProxyPermissions(userHeader, groupHeader, request) { function getProxyPermissions(userHeader, groupHeader, request) {
const user = userHeader ? request.headers.get(userHeader) : null; const user = userHeader ? request.headers.get(userHeader) : null;
const groupsString = groupHeader ? request.headers.get(groupHeader) : ""; const groupsString = groupHeader ? request.headers.get(groupHeader) : "";
@ -25,7 +23,6 @@ async function fetchProxyAuth([key, context]) {
} }
const ProxyAuthProvider = { const ProxyAuthProvider = {
key: ProxyAuthKey,
create: createProxyAuth, create: createProxyAuth,
fetch: fetchProxyAuth, fetch: fetchProxyAuth,
}; };