File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
Infrastructure/BotSharp.OpenAPI Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1919
2020 <ItemGroup >
2121
22+
2223 <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 6.5.0" />
2324 </ItemGroup >
2425
2526 <ItemGroup Condition =" '$(TargetFramework)' == 'net8.0'" >
2627 <PackageReference Include =" Microsoft.AspNetCore.Authentication.Google" Version =" 8.0.2" />
2728 <PackageReference Include =" AspNet.Security.OAuth.GitHub" Version =" 8.0.0" />
29+ <PackageReference Include =" AspNet.Security.OAuth.Keycloak" Version =" 8.0.0" />
2830 <PackageReference Include =" Microsoft.AspNetCore.Authentication.JwtBearer" Version =" 8.0.2" />
2931 <PackageReference Include =" Microsoft.AspNetCore.SpaServices.Extensions" Version =" 8.0.2" />
3032 </ItemGroup >
3133
3234 <ItemGroup Condition =" '$(TargetFramework)' == 'net6.0'" >
3335 <PackageReference Include =" Microsoft.AspNetCore.Authentication.Google" Version =" 6.0.27" />
3436 <PackageReference Include =" AspNet.Security.OAuth.GitHub" Version =" 6.0.15" />
37+ <PackageReference Include =" AspNet.Security.OAuth.Keycloak" Version =" 6.0.15" />
3538 <PackageReference Include =" Microsoft.AspNetCore.Authentication.JwtBearer" Version =" 6.0.25" />
3639 <PackageReference Include =" Microsoft.AspNetCore.SpaServices.Extensions" Version =" 6.0.26" />
3740 </ItemGroup >
Original file line number Diff line number Diff line change @@ -101,6 +101,21 @@ public static IServiceCollection AddBotSharpOpenAPI(this IServiceCollection serv
101101 } ) ;
102102 }
103103
104+ // Keycloak Identiy OAuth
105+ if ( ! string . IsNullOrWhiteSpace ( config [ "OAuth:Keycloak:ClientId" ] ) && ! string . IsNullOrWhiteSpace ( config [ "OAuth:Keycloak:ClientSecret" ] ) )
106+ {
107+ builder = builder . AddKeycloak ( options =>
108+ {
109+ options . BaseAddress = new Uri ( config [ "OAuth:Keycloak:BaseAddress" ] ) ;
110+ options . Realm = config [ "OAuth:Keycloak:Realm" ] ;
111+ options . ClientId = config [ "OAuth:Keycloak:ClientId" ] ;
112+ options . ClientSecret = config [ "OAuth:Keycloak:ClientSecret" ] ;
113+ options . AccessType = AspNet . Security . OAuth . Keycloak . KeycloakAuthenticationAccessType . Confidential ;
114+ int version = Convert . ToInt32 ( config [ "OAuth:Keycloak:Version" ] ?? "22" ) ;
115+ options . Version = new Version ( version , 0 ) ;
116+ } ) ;
117+ }
118+
104119 // Add services to the container.
105120 services . AddControllers ( )
106121 . AddJsonOptions ( options =>
Original file line number Diff line number Diff line change @@ -36,9 +36,9 @@ public async Task<ActionResult<Token>> GetToken([FromHeader(Name = "Authorizatio
3636
3737 [ AllowAnonymous ]
3838 [ HttpGet ( "/sso/{provider}" ) ]
39- public async Task < IActionResult > Authorize ( [ FromRoute ] string provider )
39+ public async Task < IActionResult > Authorize ( [ FromRoute ] string provider , string redirectUrl )
4040 {
41- return Challenge ( new AuthenticationProperties { RedirectUri = $ "page/user/me" } , provider ) ;
41+ return Challenge ( new AuthenticationProperties { RedirectUri = redirectUrl } , provider ) ;
4242 }
4343
4444 [ AllowAnonymous ]
Original file line number Diff line number Diff line change 2121 "Google" : {
2222 "ClientId" : " " ,
2323 "ClientSecret" : " "
24+ },
25+ "Keycloak" : {
26+ "BaseAddress" : " " ,
27+ "Realm" : " " ,
28+ "ClientId" : " " ,
29+ "ClientSecret" : " " ,
30+ "Version" : 22
2431 }
2532 },
2633
You can’t perform that action at this time.
0 commit comments