mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 22:37:29 +00:00
Reject extra session token segments (#18)
This commit is contained in:
parent
aa7eb32c36
commit
d558554da3
2 changed files with 5 additions and 2 deletions
|
|
@ -160,7 +160,9 @@ export function signSession(payload: Record<string, unknown>): string {
|
|||
}
|
||||
|
||||
export function verifySession(value: string): Record<string, unknown> | null {
|
||||
const [encoded, signature] = value.split(".");
|
||||
const parts = value.split(".");
|
||||
if (parts.length !== 2) return null;
|
||||
const [encoded, signature] = parts;
|
||||
if (!encoded || !signature) return null;
|
||||
|
||||
const expected = createHmac("sha256", getSessionSecret()).update(encoded).digest("base64url");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue