Hrolgar
Hrolgar
CC#
Created by Hrolgar on 11/3/2023 in #help
❔ Help with Duende Login for part of page
I am having an issue that I have been struggeling with for quite some time now. I want only part of my client blazor server to need duende Authorization. I have done this with adding @attribute [Authorize] or [AllowAnonymous], and when it needs autorization it goes into my App.Razor, and the cascadingauthenticationstate checks if it is not authroized. If not it goes into my RedirectTologin component I'll show here: App.Razor: https://pastebin.com/vTrzFD35 RedirectToLogin.razor https://pastebin.com/ZHgMxBzh This works as expected, and it goes into duende login. The login is logging in successfully . After a successfull login the duende is supposed to redirect to authentication/login-callback, and it does. It even sets the cookies in my browser, ".AspNetCore.Identity.Application", "idsrv.session" and the ".AspNetCore.Antiforgery.VMx79YeDpl8" Duende Logs after login: https://pastebin.com/2yBiWYF5 Then after the login is a success, it redirects back to the /authentication/login-callback page. I'll post the page under: LoginCallback.razor https://pastebin.com/UY6VcL9h The problem is that the user is never authenticated, even if we all agree on the authentication process on the duende side seems to be correct. The user object when printed out looks something like this: https://pastebin.com/cLVgmEFN This is the link Duende sends me back to: https://localhost:5137/authentication/login-callback?code=8750F9C493F12A2CC5DAEB72CE921995876680B58CE4A2FAC343AAD73453E703-1&scope=openid%20profile%20verification&state=https%3A%2F%2Flocalhost%3A5137%2Fcreate&session_state=sUNjennY1fbZSsGb-BzorJK6ztO-UzdEiK9fnTi3UKs.3834D93E71029967EA54DBBA84CF1AFF&iss=https%3A%2F%2Flocalhost%3A5001 Some other info Blazor Servers Program.cs: https://pastebin.com/ns9S2bad Duende's HostExtensions.cs https://pastebin.com/uRBqs21R Duende's Config.cs https://pastebin.com/41vGKEi1 Duende's Login Index.cshtml.cs https://pastebin.com/6AcdAAGb I'll be happy to provide some more information
2 replies
CC#
Created by Hrolgar on 10/28/2023 in #help
❔ Azure Linux Functions, dotnet isolated
I have an issue with my Azure Linux functions, they are made like this in terraform: https://pastebin.com/SJBK0EVc Problem I get is that when I upload code to one of them I keep getting these errors: Exceeded language worker restart retry count for runtime:dotnet-isolated. Shutting down and proactively recycling the Functions Host to recover https://aka.ms/dotnet/app-launch-failed Failed to start a new language worker for runtime: dotnet-isolated. To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=debian.11-x64 I am using dotnet 7, and my functions are supposed to be dotnet-isolated. Since this timesout and kills my functions non stop, I am hoping there is any suggestions to fix this. Any suggestions?
5 replies
CC#
Created by Hrolgar on 9/6/2023 in #help
❔ Troubleshooting Blazor Server Authentication with Duende IdentityServer: Need Help and Insights!
Hello everyone! 👋 I've successfully set up a Duende IdentityServer that works seamlessly with Asp.Net Core as a frontend client. However, I'm facing some challenges when trying to use a Blazor Server client frontend instead. I've tried applying the same technique I use with an Asp.Net Core frontend, but it just doesn't seem to work. Here's the code I'm using in the Program.cs of the Asp.Net Core client:
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;

builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://localhost:5001";
options.ClientId = "web";
options.ClientSecret = "secret";
options.ResponseType = "code";

options.Scope.Clear();
options.Scope.Add("verification");
options.ClaimActions.MapJsonKey("email_verified", "email_verified");
options.Scope.Add("openid");
options.Scope.Add("profile");
options.GetClaimsFromUserInfoEndpoint = true;
options.SaveTokens = true;
});
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;

builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://localhost:5001";
options.ClientId = "web";
options.ClientSecret = "secret";
options.ResponseType = "code";

options.Scope.Clear();
options.Scope.Add("verification");
options.ClaimActions.MapJsonKey("email_verified", "email_verified");
options.Scope.Add("openid");
options.Scope.Add("profile");
options.GetClaimsFromUserInfoEndpoint = true;
options.SaveTokens = true;
});
Followed by:
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();

app.MapRazorPages().RequireAuthorization();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();

app.MapRazorPages().RequireAuthorization();
When I run the server and then the client, it successfully redirects to the server (at localhost:5001) while waiting for authorization. However, when attempting the same setup with a Blazor Server as a client, it doesn't work. Does anyone have any insights into why this might be happening, and any suggestions on how to make it work? I'd greatly appreciate any help or advice on this matter. 🙏
5 replies