-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added various contexts to authentication events (#12)
* Added various contexts to authentication events * Fixed code doc * Upped major version due to breaking changes
- Loading branch information
Showing
10 changed files
with
92 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Source/AuthenticationHandler/Context/AuthenticationFailedContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Dnmh.Security.ApiKeyAuthentication.AuthenticationHandler.Context; | ||
|
||
/// <summary> | ||
/// The context associated with failed authentication | ||
/// </summary> | ||
public class AuthenticationFailedContext : ResultContext<ApiKeyAuthenticationOptions> | ||
{ | ||
/// <summary> | ||
/// The optional exception that occured when authentication failed. | ||
/// </summary> | ||
public Exception? Exception { get; } | ||
|
||
/// <inheritdoc/> | ||
public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, ApiKeyAuthenticationOptions options, Exception? exception) | ||
: base(context, scheme, options) | ||
{ | ||
Exception = exception; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Source/AuthenticationHandler/Context/AuthenticationSuccessContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
using System.Security.Claims; | ||
|
||
namespace Dnmh.Security.ApiKeyAuthentication.AuthenticationHandler.Context; | ||
|
||
/// <summary> | ||
/// The context associated with authentication success | ||
/// </summary> | ||
public class AuthenticationSuccessContext : ResultContext<ApiKeyAuthenticationOptions> | ||
{ | ||
/// <summary> | ||
/// The claims principle associated with the authentication success | ||
/// </summary> | ||
public ClaimsPrincipal ClaimsPrincipal { get; } | ||
|
||
/// <inheritdoc/> | ||
public AuthenticationSuccessContext(HttpContext context, AuthenticationScheme scheme, ApiKeyAuthenticationOptions options, ClaimsPrincipal claimsPrincipal) | ||
: base(context, scheme, options) | ||
{ | ||
ClaimsPrincipal = claimsPrincipal; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Dnmh.Security.ApiKeyAuthentication.AuthenticationHandler.Context; | ||
|
||
/// <summary> | ||
/// The context associated with validiting the api key. | ||
/// </summary> | ||
public class ValidationContext : BaseContext<ApiKeyAuthenticationOptions> | ||
{ | ||
/// <summary> | ||
/// The api key that needs validation | ||
/// </summary> | ||
public string ApiKey { get; } | ||
|
||
/// <inheritdoc/> | ||
public ValidationContext(HttpContext context, AuthenticationScheme scheme, ApiKeyAuthenticationOptions options, string apiKey) | ||
: base(context, scheme, options) | ||
{ | ||
ApiKey = apiKey; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters