-
-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Salesforce OAuth provider (#1011)
- Loading branch information
1 parent
21c18f6
commit bd0393d
Showing
19 changed files
with
318 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
package: "@lucia-auth/oauth" # package name | ||
type: "minor" # "major", "minor", "patch" | ||
--- | ||
|
||
Add Salesforce provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
--- | ||
title: "Salesforce" | ||
description: "Learn how to use the Salesforce OAuth provider" | ||
--- | ||
|
||
OAuth 2.0 (Authorization code) integration for Salesforce. Provider id is `salesforce`. | ||
|
||
```ts | ||
import { salesforce } from "@lucia-auth/oauth/providers"; | ||
import { auth } from "./lucia.js"; | ||
|
||
const salesforceAuth = salesforce(auth, configs); | ||
``` | ||
|
||
## `salesforce()` | ||
|
||
Scopes `oidc`, `profile`, and `id` are always included. | ||
|
||
```ts | ||
const salesforce: ( | ||
auth: Auth, | ||
configs: { | ||
clientId: string; | ||
clientSecret: string; | ||
redirectUri: string; | ||
scope?: string[]; | ||
} | ||
) => SalesforceProvider; | ||
``` | ||
|
||
##### Parameters | ||
|
||
| name | type | description | optional | | ||
| ---------------------- | ------------------------------------------ | ---------------------------------- | :------: | | ||
| `auth` | [`Auth`](/reference/lucia/interfaces/auth) | Lucia instance | | | ||
| `configs.clientId` | `string` | Salesforce OAuth app client id | | | ||
| `configs.clientSecret` | `string` | Salesforce OAuth app client secret | | | ||
| `configs.redirectUri` | `string` | an authorized redirect URI | | | ||
| `configs.scope` | `string[]` | an array of scopes | ✓ | | ||
|
||
##### Returns | ||
|
||
| type | description | | ||
| ------------------------------------------- | ------------------- | | ||
| [`SalesforceProvider`](#salesforceprovider) | Salesforce provider | | ||
|
||
## Interfaces | ||
|
||
### `SalesforceAuth` | ||
|
||
See [`OAuth2ProviderAuth`](/reference/oauth/interfaces/oauth2providerauth). | ||
|
||
```ts | ||
// implements OAuth2ProviderAuth<SalesforceAuth<_Auth>> | ||
interface SalesforceAuth<_Auth extends Auth> { | ||
getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>; | ||
validateCallback: (code: string) => Promise<SalesforceUserAuth<_Auth>>; | ||
} | ||
``` | ||
|
||
| type | | ||
| ------------------------------------------- | | ||
| [`SalesforceUserAuth`](#salesforceuserauth) | | ||
|
||
##### Generics | ||
|
||
| name | extends | default | | ||
| ------- | ---------- | ------- | | ||
| `_Auth` | [`Auth`]() | `Auth` | | ||
|
||
### `SalesforceTokens` | ||
|
||
```ts | ||
type SalesforceTokens = { | ||
accessToken: string; | ||
idToken: string; | ||
refreshToken: string | null; | ||
}; | ||
``` | ||
|
||
### `SalesforceUser` | ||
|
||
```ts | ||
type SalesforceUser = { | ||
sub: string; // URL | ||
user_id: string; | ||
organization_id: string; | ||
name: string; | ||
email?: string; | ||
email_verified: boolean; | ||
given_name: string; | ||
family_name: string; | ||
zoneinfo: string; | ||
photos: { | ||
picture: string; | ||
thumbnail: string; | ||
}; | ||
profile: string; | ||
picture: string; | ||
address?: Record<string, string>; | ||
urls: Record<string, string>; | ||
active: boolean; | ||
user_type: string; | ||
language: string; | ||
locale: string; | ||
utcOffset: number; | ||
updated_at: string; | ||
}; | ||
``` | ||
|
||
### `SalesforceUserAuth` | ||
|
||
Extends [`ProviderUserAuth`](/reference/oauth/interfaces/provideruserauth). | ||
|
||
```ts | ||
interface Auth0UserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> { | ||
salesforceUser: SalesforceUser; | ||
salesforceTokens: SalesforceTokens; | ||
} | ||
``` | ||
|
||
| properties | type | description | | ||
| ------------------ | --------------------------------------- | ----------------- | | ||
| `salesforceUser` | [`SalesforceUser`](#salesforceuser) | Salesforce user | | ||
| `salesforceTokens` | [`SalesforceTokens`](#salesforcetokens) | Access tokens etc | | ||
|
||
##### Generics | ||
|
||
| name | extends | | ||
| ------- | ---------- | | ||
| `_Auth` | [`Auth`]() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
export { | ||
createOAuth2AuthorizationUrl, | ||
createOAuth2AuthorizationUrlWithPKCE, | ||
validateOAuth2AuthorizationCode, | ||
validateOAuth2AuthorizationCode | ||
} from "./core/oauth2.js"; | ||
export { decodeIdToken } from "./core/oidc.js"; | ||
export { providerUserAuth } from "./core/provider.js"; | ||
export { OAuthRequestError } from "./core/request.js"; | ||
|
||
export type { ProviderUserAuth } from "./core/provider.js"; | ||
export type { OAuth2ProviderAuth, OAuth2ProviderAuthWithPKCE } from "./core/oauth2.js"; | ||
export type { | ||
OAuth2ProviderAuth, | ||
OAuth2ProviderAuthWithPKCE | ||
} from "./core/oauth2.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.