Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/runtime/server/lib/oauth/zitadel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { H3Event } from 'h3'
import { eventHandler, getQuery, sendRedirect } from 'h3'
import { withQuery } from 'ufo'
import { hasProtocol, withQuery } from 'ufo'
import { defu } from 'defu'
import type { RequestAccessTokenOptions } from '../utils'
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, requestAccessToken, handleState, handlePkceVerifier, handleInvalidState } from '../utils'
Expand Down Expand Up @@ -48,6 +48,7 @@
config = defu(config, useRuntimeConfig(event).oauth?.zitadel, {
authorizationParams: {},
}) as OAuthZitadelConfig
const domain = hasProtocol(config.domain) ? config.domain : `https://${config.domain}`

Check failure on line 51 in src/runtime/server/lib/oauth/zitadel.ts

View workflow job for this annotation

GitHub Actions / test

Argument of type 'string | undefined' is not assignable to parameter of type 'string'.

const query = getQuery<{ code?: string, state?: string, error?: string }>(event)

Expand All @@ -65,8 +66,8 @@
return handleMissingConfiguration(event, 'zitadel', ['clientId', 'domain'], onError)
}

const authorizationURL = `https://${config.domain}/oauth/v2/authorize`
const tokenURL = `https://${config.domain}/oauth/v2/token`
const authorizationURL = `${domain}/oauth/v2/authorize`
const tokenURL = `${domain}/oauth/v2/token`
const redirectURL = config.redirectURL || getOAuthRedirectURL(event)

// Create pkce verifier
Expand Down Expand Up @@ -123,7 +124,7 @@
const accessToken = tokens.access_token
// Fetch user info
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const user: any = await $fetch(`https://${config.domain}/oidc/v1/userinfo`, {
const user: any = await $fetch(`${domain}/oidc/v1/userinfo`, {
headers: {
Authorization: `Bearer ${accessToken}`,
Accept: 'application/json',
Expand Down
Loading