chimera
chimera
CC#
Created by Christian Dale on 3/23/2024 in #help
✅ Looking for a way to Extract information from a txt File
Parse each line https://stackoverflow.com/a/8038746 and you could just put everything before your : into the key in a Dictionary<string, string> and everything after into the value. That way you can easily access the values in memory
11 replies
CC#
Created by chimera on 8/25/2023 in #help
❔ Binding a DTO from route and body
I thought it was just me being stupid. For me that seems like an oversight as in alot of rest calls, you send an id in route and a body with changes/new entity
6 replies
CC#
Created by chimera on 6/28/2023 in #help
❔ Having trouble integrating Azure ad SSO and normal username/password
services.AddAuthentication(options => { options.DefaultAuthenticateScheme = "EQ-Bearer"; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer("EQ-Bearer", configureOptions => { configureOptions.ClaimsIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)]; configureOptions.TokenValidationParameters = tokenValidationParameters; configureOptions.SaveToken = true; configureOptions.Events = new JwtBearerEvents { OnChallenge = context => { var a = context; return Task.CompletedTask; }, OnAuthenticationFailed = context => { if (context.Exception.GetType() == typeof(SecurityTokenExpiredException)) { context.Response.Headers.Add("Token-Expired", "true"); } return Task.CompletedTask; }, OnMessageReceived = context => { var accessToken = context.Request.Query["access_token"]; var path = context.HttpContext.Request.Path; if (!string.IsNullOrEmpty(accessToken) && (path.StartsWithSegments("/hubs"))) { context.Token = accessToken; } return Task.CompletedTask; } }; }).AddMicrosoftIdentityWebApi(Configuration); And set the standard authentication like this: services.AddAuthorization(options => { var defaultAuthBuilder = new AuthorizationPolicyBuilder("EQ-Bearer"); defaultAuthBuilder = defaultAuthBuilder.RequireAuthenticatedUser(); options.DefaultPolicy = defaultAuthBuilder.Build();
3 replies
CC#
Created by chimera on 6/12/2023 in #help
❔ Validate an Azure ad token in .net 7
The exisiting JWT configuration? i need to be able to login with username/password
9 replies
CC#
Created by chimera on 6/12/2023 in #help
❔ Validate an Azure ad token in .net 7
I've tried that middleware but it seems to collide with the existing jwt configuration that is used for normal signin
9 replies
CC#
Created by chimera on 6/12/2023 in #help
❔ Validate an Azure ad token in .net 7
I have also tried this, var token = ""; string authority = "https://login.microsoftonline.com/<>/"; string clientId = "<>"; IConfigurationManager<OpenIdConnectConfiguration> configurationManager = new ConfigurationManager<OpenIdConnectConfiguration>($"{authority}.well-known/openid-configuration", new OpenIdConnectConfigurationRetriever()); OpenIdConnectConfiguration openIdConfig = await configurationManager.GetConfigurationAsync(CancellationToken.None); IdentityModelEventSource.ShowPII = true; var validationParams = new TokenValidationParameters { ValidAudience = clientId, IssuerSigningKeys = openIdConfig.SigningKeys, }; openIdConfig.SigningKeys.Dump(); var tokenHandler = new JwtSecurityTokenHandler(); tokenHandler.ValidateToken(token, validationParams, out _); but i get the error IDX10511: Signature validation failed. Keys tried: 'Microsoft.IdentityModel.Tokens.X509SecurityKey, KeyId: '[deleted]', InternalId: '[deleted]'. , KeyId: [deleted]'. Number of keys in TokenValidationParameters: '14'. Number of keys in Configuration: '0'. Matched key was in 'TokenValidationParameters'. kid: '[deleted]'. Exceptions caught: ".
9 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
Really nice to know that it works for someone in prod 🙂
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
Thanks alot 🙂
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
Cool
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
So Form Submission Field Values is still just string?
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
Good idea
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
Using regular Azure Relational DB
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
If i want to search in a date range?
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
Yea that was my thinking as well. Only thing i was thinking is the search would be slow on a db?
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
So you would serialize everything to a string value? dates etc?
29 replies
CC#
Created by chimera on 2/17/2023 in #help
❔ Designing an api that can create "fields" with different values
I may have been to vague, but the form will be custom. So the user can design it themselves. Therefore i wanna a class that represents the form name etc. and connect a list to that with the available fields to fill
29 replies
CC#
Created by Davaaron on 2/17/2023 in #help
❔ Load *.sql files (How to handle them?)
As Z's is saying, just have your queries in code. That way you can parametize them easily
12 replies