Implement (optional) SSO via OIDC (OpenID Connect) (#64)
This implements optional SSO via OIDC for logging in and signing up (for the first admin sign up or if sign up is allowed). The most requested feature! Tested with Authentik and Google! It includes a new `SimpleCache` interface (in-memory, using [`caches`](https://developer.mozilla.org/en-US/docs/Web/API/Window/caches)) for storing the state and code challenges. Closes #13
This commit is contained in:
@@ -58,6 +58,17 @@ export function generateRandomCode(length = 6) {
|
||||
return codeDigits.join('');
|
||||
}
|
||||
|
||||
/** This generates a random string, including unicode characters. */
|
||||
export function generateRandomString(length = 10) {
|
||||
const array = new Uint8Array(length * 2);
|
||||
crypto.getRandomValues(array);
|
||||
|
||||
return Array.from(array)
|
||||
.map((byte) => String.fromCharCode(byte))
|
||||
.join('')
|
||||
.slice(0, length);
|
||||
}
|
||||
|
||||
export async function generateHash(value: string, algorithm: AlgorithmIdentifier) {
|
||||
const hashedValueData = await crypto.subtle.digest(
|
||||
algorithm,
|
||||
|
||||
Reference in New Issue
Block a user