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
Copy file name to clipboardexpand all lines: _source/_posts/2024-02-29-net-scim.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ Create a directory called `okta-scim-server-dotnet`. Navigate to the directory i
43
43
- At this point using the *https://localhost:7094/swagger/index.html* you will be able to see the Swagger UI. Typically, a browser tab will automatically open; if not, manually check for the URL to the Swagger UI under `Properties/launchSettings.json` and copy/paste this URL onto the browser:
44
44
45
45
### Setup Okta (the IdP)
46
-
{% include setup/cli.md type="spa" framework="ASP.NET Core" loginRedirectUri="http://localhost:7094/swagger/oauth2-redirect.html" logoutRedirectUri="http://localhost:7094" %}
46
+
{% include setup/cli.md type="spa" loginRedirectUri="http://localhost:7094/swagger/oauth2-redirect.html" logoutRedirectUri="http://localhost:7094" %}
47
47
48
48
Note the `Issuer` and the `Client ID`. You'll need those values for your authentication configuration coming up soon.
49
49
@@ -90,7 +90,7 @@ public class Email
90
90
publicvirtualUserUser { get; set; }
91
91
}
92
92
```
93
-
Add DB context for each entity framework in the `DataModels.cs` file, i.e., to the two models we created above. We'll also add some seed data using the method `OnModelCreating`, which will be useful for testing. In this sample, we will create support for the User resource type. However, if you want to expand on this, you can use similar concepts to maintain endpoints for other resource types, such as Group. Paste the following code just below the `Email` class:
93
+
Add DB context for each entity framework in the `DataModels.cs` file, (i.e., to the two models we created above.) We'll also add some seed data using the method `OnModelCreating`, which will be useful for testing. In this sample, we will create support for the User resource type. However, if you want to expand on this, you can use similar concepts to maintain endpoints for other resource types, such as Group. Paste the following code just below the `Email` class:
94
94
```c#
95
95
publicpartialclassScimDbContext : DbContext
96
96
{
@@ -365,7 +365,7 @@ public class ScimEmail
365
365
}
366
366
```
367
367
We also need to create mappers between DB models and SCIM models to avoid many manual conversions. For this, we will use the `AutoMapper` package.
368
-
- Install dependencies by running the following commands
368
+
- Install dependencies by running the following commands:
@@ -557,7 +557,7 @@ record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
557
557
```
558
558
559
559
### Create the .NET SCIM server RESTful API endpoints
560
-
Since we have created the necessary data and SCIM models. We can move on to creating the endpoints for user lifecycle management. First, let's set up dependencies, some basic global configuration, and clean up unnecessary code
560
+
Since we have created the necessary data and SCIM models. We can move on to creating the endpoints for user lifecycle management. First, let's set up dependencies, some basic global configuration, and clean up unnecessary code.
561
561
- Install dependencies by running `dotnet add package Newtonsoft.Json`
562
562
- At the top of the `Program.cs` file, add `using` statements
563
563
```c#
@@ -619,7 +619,7 @@ app.Run();
619
619
```
620
620
621
621
### Retrieve a user
622
-
We are using minimal APIs for creating endpoints. For retrieving a user, let's create the route that expects the user's `id` in the path and responds with a single `ScimUser` object if found and a `ScimErrorResponse` if the user doesn't exist. Add the following code before `app.Run();` in the `Program.cs` file.
622
+
We are using minimal APIs for creating endpoints. For retrieving a user, let's create the route that expects the user's `id` in the path and responds with a single `ScimUser` object if found and a `ScimErrorResponse` if the user doesn't exist. Add the following code before `app.Run();` in the `Program.cs` file:
- At this point, our OAuth implementation can now can be tested on our CRUD endpoints. However, this needs an additional step. The Swagger UI should now have an `Authorize` button, click on this button, then click on the `select all` option under `Scopes` before clicking on the `Authorize` button again. If you do not authenticate, you will get `401` responses from any of the endpoints we've protected.
1805
+
- At this point, our OAuth implementation can now can be tested on our CRUD endpoints. However, this needs an additional step. The Swagger UI should now have an `Authorize` button. Click on this button, then click on the `select all` option under `Scopes` before clicking on the `Authorize` button again. If you do not authenticate, you will get `401` responses from any of the endpoints we've protected.
1806
1806
1807
1807
## Test requests to the .NET SCIM server locally using a tunnel
1808
1808
@@ -1830,7 +1830,7 @@ Keep the default settings in the **Sign-On Options** dialog, as our app doesn't
1830
1830
1831
1831
In the **Provisioning** tab of the application, press the **Configure API Integration** button and check the **Enable API Integration** checkbox. Provide the **Base URL**, which is the ngrok localtunnel URL with `/scim/v2` appended to the end. The **OAuth Bearer Token** is can be retrieved from the test you did above either from UI or curl. Press **Save** to save the settings.
1832
1832
1833
-
For example, below is a highlighted sample base URL from ngrok.
1833
+
For example, below is a highlighted sample base URL from ngrok:
1834
1834
1835
1835
{% img blog/net-scim/ngrok.jpeg alt:"Image of highlighted sample base URL from ngrok" width:"800" %}{: .center-image }
1836
1836
@@ -1870,7 +1870,7 @@ We can confirm that Tom's `active` attribute is now `false` in the Swagger UI by
1870
1870
1871
1871
Let's say Tom gets hired full-time with the company and needs access to the application again.
1872
1872
1873
-
To reactivate Tom's account, we will repeat the steps for assigning his Okta account to the application. Reactivating Tom causes Okta to send a PATCH request to your scim server, setting their `active` attribute to `true`.
1873
+
To reactivate Tom's account, we will repeat the steps for assigning his Okta account to the application. Reactivating Tom causes Okta to send a PATCH request to your SCIM server, setting their `active` attribute to `true`.
1874
1874
1875
1875
Again, we can confirm that Tom's account is now `active` through the Swagger UI by making a request to the GET Users endpoint filtering for Tom's email "tom.anderson@fake.domain".
0 commit comments