Skip to content

Commit

Permalink
Fix "Method not found:Boolean Okta.AspNet.Abstractions.OktaParams.Isr…
Browse files Browse the repository at this point in the history
…omptEnrollAuthenticator" issue (#231)

* Fix "Method not found:Boolean Okta.AspNet.Abstractions.OktaParams.IsPromptEnrollAuthenticator" issue (#228)

* Update assemblies' version.

* Update docs to show how to add custom claims in tokens (#232)

Update docs to show how to add custom claims in tokens.
  • Loading branch information
laura-rodriguez authored Jan 12, 2023
1 parent 25b59d1 commit 09d612e
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Okta.AspNet.Abstractions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
Running changelog of releases since `3.0.5`

## v4.2.1

### Bug Fixes

- Fix "Method not found:Boolean Okta.AspNet.Abstractions.OktaParams.IsPromptEnrollAuthenticator" issue (#228)

## v4.2.0

### Features
Expand Down
6 changes: 3 additions & 3 deletions Okta.AspNet.Abstractions/Okta.AspNet.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<Version>4.2.0</Version>
<Version>4.2.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -36,8 +36,8 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>okta.aspnet.public.snk</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
<AssemblyVersion>3.2.2.0</AssemblyVersion>
<FileVersion>3.2.2.0</FileVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<FileVersion>4.2.1.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
6 changes: 6 additions & 0 deletions Okta.AspNet/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
Running changelog of releases since `1.6.0`

## 3.2.2

### Bug Fixes

- Fix "Method not found:Boolean Okta.AspNet.Abstractions.OktaParams.IsPromptEnrollAuthenticator" issue (#228)

## 3.2.1

### Features
Expand Down
6 changes: 3 additions & 3 deletions Okta.AspNet/Okta.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Official Okta middleware for ASP.NET 4.6.2+. Easily add authentication and authorization to ASP.NET applications.</Description>
<Copyright>(c) 2019 Okta, Inc.</Copyright>
<Version>3.2.1</Version>
<Version>3.2.2</Version>
<Authors>Okta, Inc.</Authors>
<TargetFramework>net462</TargetFramework>
<AssemblyName>Okta.AspNet</AssemblyName>
Expand All @@ -30,8 +30,8 @@

<PropertyGroup>
<CodeAnalysisRuleSet>..\OktaSdk.ruleset</CodeAnalysisRuleSet>
<AssemblyVersion>3.0.2.1</AssemblyVersion>
<FileVersion>3.0.2.1</FileVersion>
<AssemblyVersion>3.0.2.2</AssemblyVersion>
<FileVersion>3.0.2.2</FileVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>okta.aspnet.public.snk</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
Expand Down
6 changes: 6 additions & 0 deletions Okta.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
Running changelog of releases since `3.2.0`

## v4.4.2

### Bug Fixes

- Fix "Method not found:Boolean Okta.AspNet.Abstractions.OktaParams.IsPromptEnrollAuthenticator" issue (#228)

## v4.4.1

### Features
Expand Down
4 changes: 2 additions & 2 deletions Okta.AspNetCore/Okta.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<PropertyGroup>
<Description>Official Okta middleware for ASP.NET Core 3.1+. Easily add authentication and authorization to ASP.NET Core applications.</Description>
<Copyright>(c) 2020 - present Okta, Inc. All rights reserved.</Copyright>
<Version>4.4.1</Version>
<VersionPrefix>4.4.1</VersionPrefix>
<Version>4.4.2</Version>
<VersionPrefix>4.4.2</VersionPrefix>
<Authors>Okta, Inc.</Authors>
<AssemblyName>Okta.AspNetCore</AssemblyName>
<PackageId>Okta.AspNetCore</PackageId>
Expand Down
35 changes: 32 additions & 3 deletions docs/aspnet4x-mvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,41 @@ public class HomeController : Controller

This example assumes you have a view called `Claim` whose model is of type `System.Security.Claims.Claim`. The claim types for OIDC tokens are `id_token` and `access_token` as well as `refresh_token` if available.

## Handling failures
## Hooking into OIDC events

This library exposes [OpenIdConnectEvents](https://docs.microsoft.com/en-us/previous-versions/aspnet/mt180963(v=vs.113)) so you can hook into specific events during the authentication process. For more information see [`AuthenticationFailed`](https://docs.microsoft.com/en-us/previous-versions/aspnet/mt180967(v=vs.113)).
This library exposes [OpenIdConnectEvents](https://docs.microsoft.com/en-us/previous-versions/aspnet/mt180963(v=vs.113)) so you can hook into specific events during the authentication process.
### Adding custom claims

The following is an example of how to use events to handle failures:
The following is an example of how to use events to add custom claims to the token:

```csharp
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseOktaMvc(new OktaMvcOptions()
{
// ... other configuration options removed for brevity ...
OpenIdConnectEvents = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = (notification) =>
{
notification.AuthenticationTicket.Identity.AddClaim(new Claim("CodeCustomClaimKey", "CodeCustomClaimValue"));

return Task.CompletedTask;
}
},
});
}
}
```

> Note: For more information see [`SecurityTokenValidated`](https://learn.microsoft.com/en-us/previous-versions/aspnet/mt180993(v=vs.113))
### Handling failures

The following is an example of how to use events to handle failures:

```csharp
public class Startup
Expand All @@ -300,6 +328,7 @@ public class Startup
}
}
```
> Note: For more information see [`AuthenticationFailed`](https://docs.microsoft.com/en-us/previous-versions/aspnet/mt180967(v=vs.113))
# Configuration Reference

Expand Down
36 changes: 34 additions & 2 deletions docs/aspnetcore-mvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,39 @@ public class HomeController : Controller

This example assumes you have a view called `OIDCToken` whose model is of type `TokenModel`. The OIDC tokens are `id_token` and `access_token` as well as `refresh_token` if available.

## Handling failures
## Hooking into OIDC events

In the event a failure occurs, the Okta.AspNetCore library exposes [OpenIdConnectEvents](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectevents.onauthenticationfailed) so you can hook into specific events during the authentication process. For more information See [`OnAuthenticationFailed`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectevents.onauthenticationfailed) or [`OnRemoteFailure`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.remoteauthenticationevents.onremotefailure).
In the event a failure occurs, the Okta.AspNetCore library exposes [OpenIdConnectEvents](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectevents.onauthenticationfailed) so you can hook into specific events during the authentication process.
### Customizing claims

The following is an example of how to use events to add custom claims to the token:

```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddOktaMvc(new OktaMvcOptions
{
// ... other configuration options removed for brevity ...
OpenIdConnectEvents = new OpenIdConnectEvents
{
OnTokenValidated = context =>
{
ClaimsIdentity claimsIdentity = context.Principal.Identity as ClaimsIdentity;
claimsIdentity.AddClaim(new Claim("MyCustomClaimKey", "MyCustomClaimValue"));

return Task.CompletedTask;
}
},
});
}
```

> Note: For more information See [`OnTokenValidated`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectevents.ontokenvalidated).
### Handling failures

The following is an example of how to use events to handle failures:

Expand Down Expand Up @@ -399,6 +428,9 @@ public class Startup
}
}
```

> Note: For more information See [`OnAuthenticationFailed`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.openidconnect.openidconnectevents.onauthenticationfailed) or [`OnRemoteFailure`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.remoteauthenticationevents.onremotefailure).
# Configuration Reference

The `OktaMvcOptions` class configures the Okta middleware. You can see all the available options in the table below:
Expand Down

0 comments on commit 09d612e

Please sign in to comment.