Created
January 14, 2018 22:22
-
-
Save ignas-sakalauskas/0975665c0bf87a372b549ea004892ad1 to your computer and use it in GitHub Desktop.
Custom Authorization
This file contains hidden or 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
namespace CustomAuthNetCore20.Authorization | |
{ | |
public class CustomError | |
{ | |
public string Error { get; set; } | |
public CustomError(string message) | |
{ | |
Error = message; | |
} | |
} | |
} |
This file contains hidden or 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
// ... | |
services.AddMvc(options => | |
{ | |
// All endpoints need authentication | |
// Custom auth filter | |
options.Filters.Add(new CustomAuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build())); | |
}); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment