Fix WebDAV discovery
Also fix stricter SSO providers which require the paths to match in `redirect_uri`. Probably fixes #66
This commit is contained in:
@@ -21,15 +21,15 @@ interface OidcJwtIdToken extends Record<string, string | undefined> {
|
|||||||
sub?: string;
|
sub?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const redirectUrlPath = '/oidc/callback';
|
||||||
|
|
||||||
export class OidcModel {
|
export class OidcModel {
|
||||||
static async getSignInUrl(
|
static async getSignInUrl(
|
||||||
{
|
{
|
||||||
requestPermissions,
|
requestPermissions,
|
||||||
redirectUrlPath = '/oidc/callback',
|
|
||||||
extraState = {},
|
extraState = {},
|
||||||
}: {
|
}: {
|
||||||
requestPermissions: string[];
|
requestPermissions: string[];
|
||||||
redirectUrlPath?: string;
|
|
||||||
extraState?: OidcExtraState;
|
extraState?: OidcExtraState;
|
||||||
},
|
},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@@ -154,7 +154,7 @@ export class OidcModel {
|
|||||||
|
|
||||||
const tokens = await openIdClient.authorizationCodeGrant(
|
const tokens = await openIdClient.authorizationCodeGrant(
|
||||||
oidcConfig,
|
oidcConfig,
|
||||||
new URL(`${baseUrl}?${urlSearchParams.toString()}`),
|
new URL(`${baseUrl}${redirectUrlPath}?${urlSearchParams.toString()}`),
|
||||||
{
|
{
|
||||||
pkceCodeVerifier: expectedCodeVerifier,
|
pkceCodeVerifier: expectedCodeVerifier,
|
||||||
expectedState,
|
expectedState,
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { getDataFromRequest } from '/lib/auth.ts';
|
|||||||
|
|
||||||
export const handler = [
|
export const handler = [
|
||||||
async function handleCors(request: Request, context: FreshContext<FreshContextState>) {
|
async function handleCors(request: Request, context: FreshContext<FreshContextState>) {
|
||||||
if (request.method == 'OPTIONS') {
|
const path = new URL(request.url).pathname;
|
||||||
|
|
||||||
|
if (request.method == 'OPTIONS' && path !== '/dav' && !path.startsWith('/dav/')) {
|
||||||
const response = new Response(null, {
|
const response = new Response(null, {
|
||||||
status: 204,
|
status: 204,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user