balls mcgee
balls mcgee
CC#
Created by balls mcgee on 3/26/2025 in #help
Application Insights OpenTelemetry fresh install not showing stack trace
No description
3 replies
CC#
Created by balls mcgee on 3/14/2025 in #help
Download a file in a new tab from a controller that requires auth
We want to allow our clients to download files into new tabs like images and PDFs. When we <a href="..." target=_blank ... the tab opens but doesn't have the necessary bearer token to download the file. We tried making it download a blob and then sending the user's browser there, but the url opens as a guid which makes saving the file a real pain because you don't know the original file name. It also doesn't seem to work in mobile. We are thinking about maybe making secure tokens to allow a one-time non-auth download, but that seems like more work than it should be. How can I open a file in a new tab that requires a bearer token?
5 replies
CC#
Created by balls mcgee on 3/4/2025 in #help
Detailed 401 errors SPA bearer token
I created a minimal example to replicate an issue I'm having with a SPA OIDC and a bearer token I keep getting 401 from the following setup:
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddOpenIdConnect(options =>
{
options.Authority = "http://localhost:3000";
options.RequireHttpsMetadata = false;
options.ClientId = "oidcCLIENT";
options.GetClaimsFromUserInfoEndpoint = true;
});

builder.Services.AddAuthentication(BearerTokenDefaults.AuthenticationScheme).AddBearerToken(options =>
{
options.ClaimsIssuer = "http://localhost:3000";
});
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddOpenIdConnect(options =>
{
options.Authority = "http://localhost:3000";
options.RequireHttpsMetadata = false;
options.ClientId = "oidcCLIENT";
options.GetClaimsFromUserInfoEndpoint = true;
});

builder.Services.AddAuthentication(BearerTokenDefaults.AuthenticationScheme).AddBearerToken(options =>
{
options.ClaimsIssuer = "http://localhost:3000";
});
Very simple setup. I don't know what the issue is. I just need some debugging information. I changed my appsettings.json
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
},
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Authentication": "debug",
"Microsoft.AspNetCore.Authorization": "debug"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
},
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Authentication": "debug",
"Microsoft.AspNetCore.Authorization": "debug"
},
Nothing prints in the console, though, when I get a 401 from WeatherForecast. Any help would be greatly appreciated.
1082 replies
CC#
Created by balls mcgee on 10/24/2023 in #help
❔ 415 error from HttpClient put to a controller using FromBody
(await _client.PutAsync("foo", new StringContent(5.ToString()))).EnsureSuccessStatusCode();
(await _client.PutAsync("foo", new StringContent(5.ToString()))).EnsureSuccessStatusCode();
public async Task Put([FromBody]int bar)
public async Task Put([FromBody]int bar)
error 415 (Unsupported Media Type).
2 replies
CC#
Created by balls mcgee on 3/31/2023 in #help
❔ Redirect all unauthenticated requests for an SPA to OAuth
I have an Angular SPA app. I don't want them to be able to load any of the assets on this server without a validated JWT token from IdentityServer. How can I redirect before anything is served?
4 replies
CC#
Created by balls mcgee on 10/21/2022 in #help
How to set connection strings for remote server
I'm uploading my project for the first time to another server accessible from the net. I set my secret like dotnet user-secrets set ConnectionStrings:YourDatabaseAlias ... according to Microsoft's documentation, but I cannot find a single thing about how to set those secrets in my remote server.
12 replies