-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from hbiarge/master
Add events to the TestServerHandler
- Loading branch information
Showing
15 changed files
with
293 additions
and
108 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
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
17 changes: 17 additions & 0 deletions
17
src/Acheve.TestHost/Security/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,17 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
using System; | ||
|
||
namespace Acheve.TestHost | ||
{ | ||
public class AuthenticationFailedContext : ResultContext<TestServerOptions> | ||
{ | ||
public AuthenticationFailedContext( | ||
HttpContext context, | ||
AuthenticationScheme scheme, | ||
TestServerOptions options) | ||
: base(context, scheme, options) { } | ||
|
||
public Exception Exception { get; set; } | ||
} | ||
} |
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,16 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Acheve.TestHost | ||
{ | ||
public class MessageReceivedContext : ResultContext<TestServerOptions> | ||
{ | ||
public MessageReceivedContext( | ||
HttpContext context, | ||
AuthenticationScheme scheme, | ||
TestServerOptions options) | ||
: base(context, scheme, options) { } | ||
|
||
public string Token { get; set; } | ||
} | ||
} |
70 changes: 0 additions & 70 deletions
70
src/Acheve.TestHost/Security/TestServerAuthenticationHandler.cs
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/Acheve.TestHost/Security/TestServerChallengeContext.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,24 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
using System; | ||
|
||
namespace Acheve.TestHost | ||
{ | ||
public class TestServerChallengeContext : PropertiesContext<TestServerOptions> | ||
{ | ||
public TestServerChallengeContext( | ||
HttpContext context, | ||
AuthenticationScheme scheme, | ||
TestServerOptions options, | ||
AuthenticationProperties properties) | ||
: base(context, scheme, options, properties) { } | ||
|
||
public Exception AuthenticateFailure { get; set; } | ||
|
||
public string Error { get; set; } | ||
|
||
public bool Handled { get; private set; } | ||
|
||
public void HandleResponse() => Handled = true; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...urity/TestServerAuthenticationDefaults.cs → ...e.TestHost/Security/TestServerDefaults.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
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,24 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Acheve.TestHost | ||
{ | ||
public class TestServerEvents | ||
{ | ||
public Func<AuthenticationFailedContext, Task> OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; | ||
|
||
public Func<MessageReceivedContext, Task> OnMessageReceived { get; set; } = context => Task.CompletedTask; | ||
|
||
public Func<TokenValidatedContext, Task> OnTokenValidated { get; set; } = context => Task.CompletedTask; | ||
|
||
public Func<TestServerChallengeContext, Task> OnChallenge { get; set; } = context => Task.CompletedTask; | ||
|
||
public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); | ||
|
||
public virtual Task MessageReceived(MessageReceivedContext context) => OnMessageReceived(context); | ||
|
||
public virtual Task TokenValidated(TokenValidatedContext context) => OnTokenValidated(context); | ||
|
||
public virtual Task Challenge(TestServerChallengeContext context) => OnChallenge(context); | ||
} | ||
} |
Oops, something went wrong.