proxyauth: user OpenID instead of basic auth

This commit is contained in:
Johannes Zellner
2024-04-15 12:35:03 +02:00
parent caf1c37171
commit 21d7438bbe
5 changed files with 70 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ exports = module.exports = {
start,
stop,
revokeByUserId,
getUserByAuthCode,
consumeAuthCode,
clients: {
add: clientsAdd,
get: clientsGet,
@@ -197,6 +199,28 @@ async function revokeByUserId(userId) {
revokeObjects('AccessToken');
}
async function consumeAuthCode(authCode) {
assert.strictEqual(typeof authCode, 'string');
const authData = DATA_STORE['AuthorizationCode'][authCode];
if (!authData || !authData.payload) return;
DATA_STORE['AuthorizationCode'][authCode].consumed = true;
save('AuthorizationCode');
}
async function getUserByAuthCode(authCode) {
assert.strictEqual(typeof authCode, 'string');
load('AuthorizationCode');
const authData = DATA_STORE['AuthorizationCode'][authCode];
if (!authData || !authData.payload || !authData.payload.accountId) return null;
return await users.get(authData.payload.accountId);
}
// -----------------------------
// Generic oidc node module data store model
// -----------------------------