You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An **optional** callback function for globally handling OrderCloud errors in your application. Useful for wiring up toast-like feedback.
40
40
41
+
#### **openIdConnect**`object`
42
+
An **optional** object containing configuration for single-sign-on via [OpenID Connect](https://ordercloud.io/knowledge-base/sso-via-openid-connect).
43
+
44
+
### **openIdConnect**`boolean`
45
+
Set to `true` to activate single-sign-on via OpenIDConnect in your application. If `false`, all OIDC logic (such as login redirects and token handling) will be disabled, even if configs are defined.
An array of OpenID Connect configuration objects. Each defines the settings required to authenticate against a specific identity provider. At least one configuration must be provided.
49
+
50
+
#### **openIdConnect.configs.[i].id**`string`
51
+
The ID of the [OpenID connect configuration](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create) that should be targeted for authentication
52
+
53
+
#### **openIdConnect.configs.[i].roles**`string`
54
+
An **optional** array of roles that will be requested when authenticating. If excluded, the token generated will contain any roles assigned to the user. Unless you have a specific reason for limiting roles, we recommend omitting this option.
An **optional** path to redirect the user to after returning from the identity provider. See [here](https://ordercloud.io/knowledge-base/sso-via-openid-connect#deep-linking) for more information
**optional** query parameters passed along to the `AuthorizationEndpoint`. See [here](https://ordercloud.io/knowledge-base/sso-via-openid-connect) for more information
64
+
65
+
#### **openIdConnect.autoRedirect**`boolean`
66
+
True will automatically redirect the user to the first openIdConnect config stored if the token is expired, or invalid. This is a simplified use case. For more control, or when you need to handle multiple identity providers set this to false and handle redirect on your own by calling `loginWithOpenIdConnect`
Query parameter name where the OrderCloud access token is stored after login. For example, if [AppStartUrl](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create) is `https://my-application.com/login?token={0}`, use `token`
70
+
71
+
### **openIdConnect.refreshTokenQueryParamName**
72
+
The **optional** query parameter name for the refresh token after login. Example: if [AppStartUrl](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create) is `https://my-application.com/login?token={0}&refresh={3}`, use `refresh`
The **optional** query parameter name for the identity provider access token after login. Example: if [AppStartUrl](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create) is `https://my-application.com/login?token={0}&idptoken={1}`, use `idptoken`
77
+
41
78
## `useOrderCloudContext()` hook
42
79
This hook returns the OrderCloud context that the OrderCloudProvider sets up based on your provided options. If anonymous authentication is allowed the OrderCloud context will automatically be in an authenticated state on first page load (shortly after the first React lifecycle).
43
80
@@ -53,6 +90,9 @@ When true, the currently active OrderCloud access token is a _registered_ user (
An asyncrhonous callback method for building a login form for your application. When **rememberMe** is set to `true`, the `OrderCloudProvider` will attempt to store and use the `refresh_token` as long as it is valid. It is not necessary to do anything with the `AccessToken` response as this method will take care of managing the active token and authentication state for you.
A method for manually redirecting a user to the identity provider login page defined by the openIdConnectId. To use this method you must define the relevent `openIdConnect` properties
95
+
56
96
#### **logout**: `() => void`
57
97
A callback for logging out a registered user from your application. This will also clear the Tanstack query client cache for OrderCloud API calls, forcing any actively used queries to refetch once anonymous auth takes over again or the user logs back in.
* Enables or disables OpenID Connect authentication.
5
+
*
6
+
* Set to `true` to activate OIDC support in your application. If `false`, all OIDC logic
7
+
* (such as login redirects and token handling) will be disabled, even if configs are defined.
8
+
*/
9
+
enabled: boolean
10
+
/**
11
+
* An array of OpenID Connect configuration objects.
12
+
* Each defines the settings required to authenticate against a specific identity provider.
13
+
* At least one configuration must be provided.
14
+
*/
15
+
configs: IOpenIdConnectConfig[]
16
+
/**
17
+
* True will automatically redirect the user to the
18
+
* first openIdConnect config stored if the token is expired, or invalid.
19
+
* This is a simplified use case. For more control, or when you need to
20
+
* handle multiple identity providers set this to false and handle redirect on your
21
+
* own by calling `loginWithOpenIdConnect`
22
+
*/
23
+
autoRedirect?: boolean
24
+
/**
25
+
* The name of the query parameter under which the ordercloud access token will be stored under after successful login.
26
+
* This will vary based on your [OpenIdConnect.AppStartUrl](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create).
27
+
* For example if your `AppStartUrl` is `https://my-buyer-application.com/login?token={0}` then the value should be `token`
28
+
*/
29
+
accessTokenQueryParamName: string
30
+
/**
31
+
* The **optional** name of the query parameter under which the ordercloud refresh token will be stored
32
+
* under after successful login. This will vary based on your [OpenIdConnect.AppStartUrl](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create).
33
+
* For example if your `AppStartUrl` is `https://my-buyer-application.com/login?token={0}&refresh={3}` then the value should be `refresh`
34
+
*/
35
+
refreshTokenQueryParamName?: string
36
+
/**
37
+
* The **optional** name of the query parameter under which the idp access token will be stored
38
+
* under after successful login. This will vary based on your [OpenIdConnect.AppStartUrl](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create).
39
+
* For example if your `AppStartUrl` is `https://my-buyer-application.com/login?token={0}&idptoken={1}` then the value should be `idptoken`
40
+
*/
41
+
idpAccessTokenQueryParamName?: string
42
+
/**
43
+
* An **optional** path to redirect the user to after returning from the identity provider.
44
+
* See [here](https://ordercloud.io/knowledge-base/sso-via-openid-connect#deep-linking) for more information
45
+
* This global setting will be used if not overridden by the `appStartPath` in the individual OpenID Connect configurations.
46
+
* Call `setAppStartPath()` to change this value at runtime.
47
+
*/
48
+
appStartPath?: string
49
+
/**
50
+
* **optional** query parameters passed along to the `AuthorizationEndpoint`.
51
+
* See [here](https://ordercloud.io/knowledge-base/sso-via-openid-connect) for more information
52
+
* This global setting will be used if not overridden by the `customParams` in the individual OpenID Connect configurations.
53
+
* Call `setCustomParams()` to change this value at runtime.
54
+
*/
55
+
customParams?: string
56
+
}
57
+
58
+
exportinterfaceIOpenIdConnectConfig
59
+
{
60
+
/**
61
+
* The ID of the [OpenID connect configuration](https://ordercloud.io/api-reference/authentication-and-authorization/open-id-connects/create)
62
+
* that should be targeted for authentication
63
+
*/
64
+
id: string
65
+
/**
66
+
* An **optional** array of roles that will be requested when authenticating.
67
+
* If excluded, the token generated will contain any roles assigned to the user.
68
+
* Unless you have a specific reason for limiting roles, we recommend omitting this option.
69
+
*/
70
+
roles?: string[]
71
+
/**
72
+
* An **optional** OrderCloud clientId to authenticate against.
73
+
* By default, will use `clientId` at the root of the provider settings.
74
+
*/
75
+
clientId?: string
76
+
/**
77
+
* An **optional** path to redirect the user to after returning from the identity provider.
78
+
* See [here](https://ordercloud.io/knowledge-base/sso-via-openid-connect#deep-linking) for more information
79
+
* call `setAppStartPath(openIdConnectConfigId)` to change this value at runtime.
80
+
*/
81
+
appStartPath?: string
82
+
83
+
/**
84
+
* **optional** query parameters passed along to the `AuthorizationEndpoint`.
85
+
* See [here](https://ordercloud.io/knowledge-base/sso-via-openid-connect) for more information
86
+
* call `setCustomParams(openIdConnectConfigId)` to change this value at runtime.
0 commit comments