Skip to content

Commit

Permalink
fix(authentication-oauth): Fix bug and properly set Grant defaults (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cciocov authored Jun 11, 2022
1 parent d8104a1 commit cb93bb9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/authentication-oauth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const setup = (options: OauthSetupSettings) => (app: Application) => {
const { strategyNames } = service

// Set up all the defaults
const { prefix = '/oauth' } = oauth.defaults || {}
const port = app.get('port')
let host = app.get('host')
let protocol = 'https'
Expand All @@ -44,20 +43,21 @@ export const setup = (options: OauthSetupSettings) => (app: Application) => {
}

const grant = defaultsDeep(
{},
omit(oauth, ['redirect', 'origins']),
{
defaults: {
prefix,
origin: `${oauth?.defaults?.protocol ?? protocol}://${oauth?.defaults?.host ?? host}`,
transport: oauth?.defaults?.transport ?? 'session',
prefix: '/oauth',
origin: `${protocol}://${host}`,
transport: 'session',
response: ['tokens', 'raw', 'profile']
}
},
omit(oauth, ['redirect', 'origins'])
}
)

const getUrl = (url: string) => {
const { defaults } = grant
return `${defaults.origin}${prefix}/${url}`
return `${defaults.origin}${defaults.prefix}/${url}`
}

each(grant, (value, name) => {
Expand Down

0 comments on commit cb93bb9

Please # to comment.