mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Switch to authentication using bearer token.
This commit is contained in:
parent
698d4d2687
commit
d8e831db50
8 changed files with 33 additions and 35 deletions
11
lib/auth.js
11
lib/auth.js
|
|
@ -1,12 +1,15 @@
|
|||
import { parse } from 'cookie';
|
||||
import { parseSecureToken, parseToken } from './crypto';
|
||||
import { AUTH_COOKIE_NAME, TOKEN_HEADER } from './constants';
|
||||
import { TOKEN_HEADER } from './constants';
|
||||
import { getWebsiteById } from './queries';
|
||||
|
||||
export async function getAuthToken(req) {
|
||||
const token = parse(req.headers.cookie || '')[AUTH_COOKIE_NAME];
|
||||
try {
|
||||
const token = req.headers.authorization;
|
||||
|
||||
return parseSecureToken(token);
|
||||
return parseSecureToken(token.split(' ')[1]);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function isValidToken(token, validation) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue