Skip to content

Commit

Permalink
feat(providers): make issuer configurable on Salesforce (#4658)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed May 31, 2022
1 parent 0a7a916 commit 358b80d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/next-auth/src/providers/salesforce.js

This file was deleted.

32 changes: 32 additions & 0 deletions packages/next-auth/src/providers/salesforce.ts
@@ -0,0 +1,32 @@
import type { OAuthConfig, OAuthUserConfig } from "."

export interface SalesforceProfile extends Record<string, any> {
sub: string
nickname: string
email: string
picture: string
}

export default function Salesforce<P extends SalesforceProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
const { issuer = "https://login.salesforce.com" } = options
return {
id: "salesforce",
name: "Salesforce",
type: "oauth",
authorization: `${issuer}/services/oauth2/authorize?display=page`,
token: `${issuer}/services/oauth2/token`,
userinfo: `${issuer}/services/oauth2/userinfo`,
profile(profile) {
return {
id: profile.user_id,
name: null,
email: null,
image: profile.picture,
}
},
checks: ["none"],
options,
}
}

1 comment on commit 358b80d

@mrcampbell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happened, but all my apps using this code stopped working, throwing this error:

[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error unexpected iss value, expected undefined, got: https://login.salesforce.com {
  error: {
    message: 'unexpected iss value, expected undefined, got: https://login.salesforce.com',
    stack: 'RPError: unexpected iss value, expected undefined, got: https://login.salesforce.com\n' +
      '    at Client.validateJWT (/Users/mikecampbell/shep-fly/core/node_modules/openid-client/lib/client.js:906:15)\n' +
      '    at Client.validateIdToken (/Users/mikecampbell/shep-fly/core/node_modules/openid-client/lib/client.js:741:60)\n' +
      '    at Client.callback (/Users/mikecampbell/shep-fly/core/node_modules/openid-client/lib/client.js:486:18)\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
      '    at async oAuthCallback (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/core/lib/oauth/callback.js:112:16)\n' +
      '    at async Object.callback (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/core/routes/callback.js:50:11)\n' +
      '    at async NextAuthHandler (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/core/index.js:176:28)\n' +
      '    at async NextAuthNextHandler (/Users/mikecampbell/shep-fly/core/node_modules/next-auth/next/index.js:23:19)\n' +
      '    at async /Users/mikecampbell/shep-fly/core/node_modules/next-auth/next/index.js:59:32\n' +
      '    at async Object.apiResolver (/Users/mikecampbell/shep-fly/core/node_modules/next/dist/server/api-utils/node.js:185:9)',
    name: 'RPError'
  },
  providerId: 'salesforce',
  message: 'unexpected iss value, expected undefined, got: https://login.salesforce.com'
}

Please sign in to comment.