Authorising Umbraco front-end using Open Id Connect with an external provider (OneLogin)
We are trying to create an Umbraco site where the users will be asked to log in before they can view the content. Our identity provider is OneLogin, and we have built a vanilla .NET Core MVC sample site where authentication works fine. However, we put the same code in the Startup.cs class of our Umbraco solution and navigate to a method on a surface controller which has the [Authorize] attribute, and we find although we can login, we get 'stuck' at the callback stage as in the image below
The code we have put in the Startup.cs class, ConfigureServices method is:
I've tried going through the information at https://www.scottbrady91.com/umbraco/frontend-members-sso-openid-connect which I got working but we didn't want to use the Members part of Umbraco, we just want to be able to authorise with our OneLogin identity provider. Can anyone help with this?
For anyone else trying to get this working I figured it out; I needed to be more explicit about the default authentication scheme. This was how I configured the Startup.cs class, and now I can put the [Authorize] attribute on my restricted surface controller methods, and the user is taken to OneLogin to log in if they are not already signed in. Don't forget the app.UseAuthentication(); line in the Configure method too. Here is how I configured the Startup.cs class, ConfigureServices method:
Hi Virginia,
Thank you for sharing above code. It's really helpful.
can you please let me know one more thing. that how can we navigate to "Login" page when user is not authorize.
How you call that surface controller from startup/Program page.
Authorising Umbraco front-end using Open Id Connect with an external provider (OneLogin)
We are trying to create an Umbraco site where the users will be asked to log in before they can view the content. Our identity provider is OneLogin, and we have built a vanilla .NET Core MVC sample site where authentication works fine. However, we put the same code in the Startup.cs class of our Umbraco solution and navigate to a method on a surface controller which has the [Authorize] attribute, and we find although we can login, we get 'stuck' at the callback stage as in the image below
The code we have put in the Startup.cs class, ConfigureServices method is:
I've tried going through the information at https://www.scottbrady91.com/umbraco/frontend-members-sso-openid-connect which I got working but we didn't want to use the Members part of Umbraco, we just want to be able to authorise with our OneLogin identity provider. Can anyone help with this?
We are using Umbraco 9.4.3
For anyone else trying to get this working I figured it out; I needed to be more explicit about the default authentication scheme. This was how I configured the Startup.cs class, and now I can put the [Authorize] attribute on my restricted surface controller methods, and the user is taken to OneLogin to log in if they are not already signed in. Don't forget the app.UseAuthentication(); line in the Configure method too. Here is how I configured the Startup.cs class, ConfigureServices method:
Hi Virginia, Thank you for sharing above code. It's really helpful. can you please let me know one more thing. that how can we navigate to "Login" page when user is not authorize.
How you call that surface controller from startup/Program page.
Thanks in advance.
is working on a reply...