Skip to content

Commit 82f3c83

Browse files
isemonaalisaduncanColton Beach
authored
Apply suggestions from code review
Co-authored-by: Alisa <7586237+alisaduncan@users.noreply.github.com> Co-authored-by: Colton Beach <98902851+cbeac243@users.noreply.github.com>
1 parent e521360 commit 82f3c83

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_source/_posts/2024-02-29-net-scim.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Create a directory called `okta-scim-server-dotnet`. Navigate to the directory i
4343
- 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:
4444

4545
### 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" %}
4747

4848
Note the `Issuer` and the `Client ID`. You'll need those values for your authentication configuration coming up soon.
4949

@@ -90,7 +90,7 @@ public class Email
9090
public virtual User User { get; set; }
9191
}
9292
```
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:
9494
```c#
9595
public partial class ScimDbContext : DbContext
9696
{
@@ -365,7 +365,7 @@ public class ScimEmail
365365
}
366366
```
367367
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:
369369
- `dotnet add package AutoMapper`
370370
- `dotnet add package Automapper.Extensions.Microsoft.DependencyInjection`
371371
- Add Mappings to `ScimModels.cs`:
@@ -557,7 +557,7 @@ record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
557557
```
558558

559559
### 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.
561561
- Install dependencies by running `dotnet add package Newtonsoft.Json`
562562
- At the top of the `Program.cs` file, add `using` statements
563563
```c#
@@ -619,7 +619,7 @@ app.Run();
619619
```
620620

621621
### 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:
623623
```c#
624624
var scimPrefix = "/scim/v2";
625625
var userRoute = $"{scimPrefix}/users";
@@ -1802,7 +1802,7 @@ app.MapPatch(userRoute + "/{id}", async Task<IResult> (int id, [FromBody] JsonDo
18021802
app.Run();
18031803
```
18041804

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.
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.
18061806

18071807
## Test requests to the .NET SCIM server locally using a tunnel
18081808

@@ -1830,7 +1830,7 @@ Keep the default settings in the **Sign-On Options** dialog, as our app doesn't
18301830

18311831
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.
18321832

1833-
For example, below is a highlighted sample base URL from ngrok.
1833+
For example, below is a highlighted sample base URL from ngrok:
18341834

18351835
{% img blog/net-scim/ngrok.jpeg alt:"Image of highlighted sample base URL from ngrok" width:"800" %}{: .center-image }
18361836

@@ -1870,7 +1870,7 @@ We can confirm that Tom's `active` attribute is now `false` in the Swagger UI by
18701870

18711871
Let's say Tom gets hired full-time with the company and needs access to the application again.
18721872

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`.
18741874

18751875
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".
18761876

0 commit comments

Comments
 (0)