3

I need to implement OAuth2 login on my Umbraco website for the frontend part.

I have found a lot of information and tutorials of how to do this on the backoffice part, but none of them describes how to do it in the frontend.

I am gonna use an inhouse Oauth2 authorization server.

I have the following questions right now:

  1. I need help writing the template code. Could just be a button saying 'login' but how do I hook it up to the authentication middleware?
  2. Our OAuth2 implementation returns a JWT token that contains a users rights. Is it possible to protect views according to the specified rights in the JWT?

Any help is appreciated.

Jesper Plantener
  • 229
  • 3
  • 16

1 Answers1

4

I used the AuthU package by @mattbrailsford for this, it works really nicely.

PM> Install-Package Our.Umbraco.AuthU

There is good documentation on his github page: https://github.com/mattbrailsford/umbraco-authu.

Even if this is not what you want I recommend looking at his code for ideas, he also uses a JWT token: https://github.com/mattbrailsford/umbraco-authu/blob/master/src/Our.Umbraco.AuthU/Services/JwtTokenService.cs

Tim Pickin
  • 369
  • 4
  • 15
  • Hello, im trying to use this package when ever i try to get the token at the path i go for: /oauth/tokenusername=joebloggs&password=password1234&grant_type=password ------Always Response with: { "invalid_grant": "Invalid grant_type" } – IbraHim M. Nada Sep 30 '18 at 13:33
  • @IbraHimM.Nada do you not need a question mark between token and username, so: /oauth/token?username=joebloggs&password=password1234&grant_type=password – Tim Pickin Oct 01 '18 at 08:57
  • yes i know its a mistake in the question i have put it but still – IbraHim M. Nada Oct 01 '18 at 09:03
  • @IbraHimM.Nada, sorry I do not know, maybe if you ask a proper question about this, not just in the comments then someone will be more likely to see it who can help. – Tim Pickin Oct 02 '18 at 08:45