MCPcopy Create free account
hub / github.com/TryCatchLearn/Overflow / AddKeycloakAuthentication

Method AddKeycloakAuthentication

Common/AuthExtensions.cs:9–35  ·  view source on GitHub ↗
(this IServiceCollection services)

Source from the content-addressed store, hash-verified

7public static class AuthExtensions
8{
9 public static IServiceCollection AddKeycloakAuthentication(this IServiceCollection services)
10 {
11 services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
12 .AddKeycloakJwtBearer(
13 serviceName: "keycloak",
14 realm: "overflow",
15 options =>
16 {
17 options.RequireHttpsMetadata = false;
18 options.Audience = "overflow";
19 options.TokenValidationParameters = new TokenValidationParameters
20 {
21 ValidIssuers = [
22 "http://localhost:6001/realms/overflow",
23 "http://keycloak:8080/realms/overflow",
24 "http://id.overflow.local/realms/overflow",
25 "https://id.overflow.local/realms/overflow",
26 "https://overflow-id.trycatchlearn.com/realms/overflow",
27 ],
28 ClockSkew = TimeSpan.Zero,
29 };
30 });
31
32 services.AddAuthorizationBuilder();
33
34 return services;
35 }
36}

Callers 3

Program.csFile · 0.80
Program.csFile · 0.80
Program.csFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected