I am currently trying to implement a login feature on our website using Auth0.
I’m able to log in I’m able to retrieve/use the credentials received from Auth0 but as soon as I’m logged in and submit a form (Umbraco Forms) I get the following error:
I don’t need to store anything in Umbraco as I just need to retrieve some values from the claims returned by Auth0. This is why it’s not implemented as an external login provider, which seems to be causing the problem I’m facing.
Can I in anyway implement this without storing anything as members in Umbraco?
My implementation
I have followed the basics from the Auth0 Quickstarts section:
Add Login to your ASP.NET OWIN Application.
In startup.cs
I have added the following in ConfigureServices()
:
builder.Services.AddAuth0WebAppAuthentication(options =>
{
options.Domain = this._config.GetValue<string>(ConfigKeys.Auth0.Domain) ?? throw new ArgumentNullException(nameof(ConfigKeys.Auth0.Domain));
options.ClientId = this._config.GetValue<string>(ConfigKeys.Auth0.ClientId) ?? throw new ArgumentNullException(nameof(ConfigKeys.Auth0.ClientId));
options.CallbackPath = "/auth0/callback/";
});
Logging the visitor in is handled by a method in a SurfaceController:
public async Task Login(string returnUrl = "/")
{
if (!this.Url.IsLocalUrl(returnUrl))
{
returnUrl = "/";
}
AuthenticationProperties authenticationProperties = new LoginAuthenticationPropertiesBuilder()
.WithRedirectUri(returnUrl)
.WithScope("openid profile email")
.Build();
await this.HttpContext.ChallengeAsync(
Auth0Constants.AuthenticationScheme,
authenticationProperties
);
}
Once signed, the following session cookies is set in my browser:
I am running Umbraco 13.7.2 and using Umbraco Forms 13.3.3.