Guest User

Untitled

a guest
Nov 5th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class AuthorizationServerProvider : OAuthAuthorizationServerProvider
  2. {
  3. public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
  4. {
  5. context.Validated();
  6. }
  7. public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
  8. {
  9. var identity = new ClaimsIdentity(context.Options.AuthenticationType);
  10. if (context.UserName == "user" && context.Password == "password")
  11. {
  12. identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
  13. identity.AddClaim(new Claim("username", "user"));
  14. identity.AddClaim(new Claim(ClaimTypes.Name, "RaviRanjanKr"));
  15. context.Validated(identity);
  16. }
  17. else
  18. {
  19. context.SetError("invalid_grant", "Wrong credentials Used. Please Try again");
  20. return;
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment