From d3cbca3571a08f1dab5065cc9f7c90ec77c4da85 Mon Sep 17 00:00:00 2001 From: Aaron Dalton Date: Sun, 4 Feb 2024 22:02:18 -0500 Subject: [PATCH] Fix provider access --- src/utils/auth/auth-helpers.js | 6 +++--- src/utils/auth/null.js | 2 -- src/utils/auth/proxy.js | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/utils/auth/auth-helpers.js b/src/utils/auth/auth-helpers.js index 50f62db2..aeb046dc 100644 --- a/src/utils/auth/auth-helpers.js +++ b/src/utils/auth/auth-helpers.js @@ -2,12 +2,12 @@ import ProxyAuthProvider from "./proxy"; import NullAuthProvider from "./null"; const AuthProviders = { - NullAuthProvider, - ProxyAuthProvider, + null: NullAuthProvider, + proxy: ProxyAuthProvider, }; function getProviderByKey(key) { - return AuthProviders.find((provider) => provider.key === key) ?? NullAuthProvider; + return AuthProviders[key] || NullAuthProvider; } function authAllow({ user, groups }, item) { diff --git a/src/utils/auth/null.js b/src/utils/auth/null.js index 686e5e0a..009c5b7c 100644 --- a/src/utils/auth/null.js +++ b/src/utils/auth/null.js @@ -1,5 +1,4 @@ const NullPermissions = { user: null, groups: [] }; -const NullAuthKey = "none"; function createNullAuth() { return { @@ -15,7 +14,6 @@ async function fetchNullAuth([key]) { } const NullAuthProvider = { - key: NullAuthKey, create: createNullAuth, fetch: fetchNullAuth, }; diff --git a/src/utils/auth/proxy.js b/src/utils/auth/proxy.js index 384e17f8..98789a18 100644 --- a/src/utils/auth/proxy.js +++ b/src/utils/auth/proxy.js @@ -1,7 +1,5 @@ // '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. -const ProxyAuthKey = "proxy"; - function getProxyPermissions(userHeader, groupHeader, request) { const user = userHeader ? request.headers.get(userHeader) : null; const groupsString = groupHeader ? request.headers.get(groupHeader) : ""; @@ -25,7 +23,6 @@ async function fetchProxyAuth([key, context]) { } const ProxyAuthProvider = { - key: ProxyAuthKey, create: createProxyAuth, fetch: fetchProxyAuth, };