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
Added a sample demonstrating 3rd party authentication with OKTA (microsoft#205)
* Added a sample demonstrating 3rd party authentication with OKTA
* Typos, added steps to README, cleaning up code
* Added some details to README
* Added screenshots to README
---------
Co-authored-by: adilei <adileibowiz@microsoft.com>
This custom canvas demonstates how an access token obtained from a 3rd party identity provider, like OKTA, can be used in the context of a Copilot Studio sign-in flow.
4
+
5
+
## Getting started
6
+
7
+
To run this sample, including the end-to-end SSO flow with OKTA, you will need to:
8
+
9
+
1. Deploy [index.html](./public/index.html) and [signout.html](./public/signout.html) on a remote or local server
10
+
2. Create an OKTA developer account, or use an existing one
11
+
3. Create a new app integration in OKTA
12
+
4. Configure the default access policy in the OTKA authorization server
13
+
5. Retrieve the token endpoint for a custom copilot that is configured with manual authentication
14
+
6. Update configuration values in index.html
15
+
16
+
## Detailed instructions
17
+
18
+
### Deploy the sample files
19
+
20
+
Deploy [index.html](./public/index.html) and [signout.html](./public/signout.html) on a local or a remote server, so they are availabe via two URLs. For example: [http://localhost:8080/index.html](http://localhost:8080/index.html) and [http://localhost:8080/signout.html](http://localhost:8080/signout.html)
21
+
22
+
### Configure OKTA
23
+
24
+
1. Sign up for an [OKTA developer account](https://developer.okta.com/signup/)
25
+
2. Sign in to the OKTA admin dashboard at **https://{your domain}-admin.okta.com/** and create a new app integration with the following details.
| Grant type | Authorization Code, Interaction Code |
33
+
| Sign-in redirect URIs | the URL to index.html |
34
+
| Sign-out redirect URIs | the URL to signout.html |
35
+
| Trusted origins | your base URL, for example http://localhost:8080|
36
+
| Assignments | allow access to specific users or groups based on your requirements |
37
+
38
+
3. After creating the app integration, note its Client ID
39
+
4.**Index.html** uses the OKTA sign-in widget which relies on the Interaction Code sign-in flow. To enable the Interaction Code flow:
40
+
41
+
1. Navigate to the API settings page in **https://{your domain}.okta.com/admin/oauth2/as**
42
+
2. Under Authorization Servers, edit the default authorization server
43
+
3. Under Access Policies, edit the default policy rule
44
+
4. Under "IF Grant type is" -> Other grants, click on **Interaction Code**.
45
+
5. Update the rule
46
+
47
+
48
+
5. You should also make shoure that CORS has been enabled for your base URL. In the OKTA admin center, navigate to Security -> API -> Trusted Origins. You base url (e.g. http://localhost:8080) should appear under "Trusted Origins" with CORS enabled. In case your base url is missing, add the url with CORS enabled.
49
+
50
+
51
+
### Configure authentication in Copilot Studio, and obtain the token endpoint
52
+
53
+
1. This SSO pattern will work for copilots configured with [manual authentication and any OAuth authentication provider](https://learn.microsoft.com/en-us/microsoft-copilot-studio/configuration-end-user-authentication#manual-authentication-fields). Since it is a passthrough pattern, in which the token is sent to Copilot Studio, but not validated, it will even work when no values are provided for an authentication provider. To configure manual authentication without providing any real values, select "Azure Active Directory v2" and enter **placeholder** in both client ID and secret.
54
+
55
+
<palign="center">
56
+
<imgsrc="./img/placeholder.png"alt="Manual authentication without real values">
57
+
<br>
58
+
<em>Manual authentication without real values</em>
59
+
</p>
60
+
61
+
> [!IMPORTANT]
62
+
> When using "placeholder" instead of real values, SSO will not work in the test canvas.
63
+
> After making any changes to the copilot's authentication settings, publish the copilot.
64
+
65
+
2. Obtain the copilot's token endpoint from Settings -> Channels -> Mobile App
66
+
67
+
### Populate configuration values in index.html
68
+
69
+
1. Populate the following values in index.html, based on your configuration
| baseUrl | your OKTA domain, for example: https://mydomain.okta.com/|
74
+
| clientID | The Client ID of the OKTA application |
75
+
| redirectUri | the URL for index.html, for example: http://localhost:8080/src/index.html|
76
+
| issuer | {your OKTA domain}/oauth2/default, for example: https://mydomain.okta.com/oauth2/default|
77
+
| tokenEndpoint | Your copilot's token endpoint |
78
+
| postLogoutRedirectUri | he URL for signout.html, for example: http://localhost:8080/src/signout.html|
79
+
80
+
2. Publish or save index.html, depending if it is deployed locally or remotely
81
+
82
+
### Test the SSO flow
83
+
84
+
After signing-in using the OKTA sign-in widget, the user's access token will be sent to Copilot Studio and stored in ***System.User.AccessToken***, which can be used to make calls to protected APIs
postLogoutRedirectUri: '{the URL for signout.html}'// For example, 'http://127.0.0.1:5501/CopilotStudioSamples/3rdPartySSOWithOKTA/public/signout.html'
135
+
});
136
+
}
137
+
138
+
// Utility function
139
+
asyncfunctionfetchJSON(url,options={}){
140
+
constres=awaitfetch(url,{
141
+
...options,
142
+
headers: {
143
+
...options.headers,
144
+
accept: 'application/json'
145
+
}
146
+
});
147
+
148
+
if(!res.ok){
149
+
thrownewError(`Failed to fetch JSON due to ${res.status}`);
0 commit comments