@@ -46,18 +46,7 @@ public static AuthenticationBuilder AddCloudFoundryOAuth(this AuthenticationBuil
4646 /// <param name="config">Your application configuration. Be sure to include the <see cref="CloudFoundryConfigurationProvider"/></param>
4747 /// <returns><see cref="AuthenticationBuilder"/> configured to use OAuth with UAA or Pivotal SSO</returns>
4848 public static AuthenticationBuilder AddCloudFoundryOAuth ( this AuthenticationBuilder builder , string authenticationScheme , string displayName , IConfiguration config )
49- {
50- builder . AddOAuth < CloudFoundryOAuthOptions , CloudFoundryOAuthHandler > ( authenticationScheme , displayName , ( options ) =>
51- {
52- var securitySection = config . GetSection ( CloudFoundryDefaults . SECURITY_CLIENT_SECTION_PREFIX ) ;
53- securitySection . Bind ( options ) ;
54- options . SetEndpoints ( GetAuthDomain ( securitySection ) ) ;
55-
56- var info = config . GetSingletonServiceInfo < SsoServiceInfo > ( ) ;
57- CloudFoundryOAuthConfigurer . Configure ( info , options ) ;
58- } ) ;
59- return builder ;
60- }
49+ => builder . AddCloudFoundryOAuth ( authenticationScheme , displayName , config , ( _ , _ ) => { } ) ;
6150
6251 /// <summary>
6352 /// Adds OAuth middleware and configuration for using UAA or Pivotal SSO for user authentication
@@ -93,6 +82,13 @@ public static AuthenticationBuilder AddCloudFoundryOAuth(this AuthenticationBuil
9382 {
9483 builder . AddOAuth < CloudFoundryOAuthOptions , CloudFoundryOAuthHandler > ( authenticationScheme , displayName , ( options ) =>
9584 {
85+ var securitySection = config . GetSection ( CloudFoundryDefaults . SECURITY_CLIENT_SECTION_PREFIX ) ;
86+ securitySection . Bind ( options ) ;
87+ options . SetEndpoints ( GetAuthDomain ( securitySection ) ) ;
88+
89+ var info = config . GetSingletonServiceInfo < SsoServiceInfo > ( ) ;
90+ CloudFoundryOAuthConfigurer . Configure ( info , options ) ;
91+
9692 configurer ( options , config ) ;
9793 } ) ;
9894 return builder ;
@@ -126,18 +122,7 @@ public static AuthenticationBuilder AddCloudFoundryOpenIdConnect(this Authentica
126122 /// <param name="config">Your application configuration. Be sure to include the <see cref="CloudFoundryConfigurationProvider"/></param>
127123 /// <returns><see cref="AuthenticationBuilder"/> configured to use OpenID Connect with UAA or Pivotal SSO</returns>
128124 public static AuthenticationBuilder AddCloudFoundryOpenIdConnect ( this AuthenticationBuilder builder , string authenticationScheme , string displayName , IConfiguration config )
129- {
130- builder . AddOpenIdConnect ( authenticationScheme , displayName , options =>
131- {
132- var cloudFoundryOptions = new CloudFoundryOpenIdConnectOptions ( ) ;
133- var securitySection = config . GetSection ( CloudFoundryDefaults . SECURITY_CLIENT_SECTION_PREFIX ) ;
134- securitySection . Bind ( cloudFoundryOptions ) ;
135-
136- var info = config . GetSingletonServiceInfo < SsoServiceInfo > ( ) ;
137- CloudFoundryOpenIdConnectConfigurer . Configure ( info , options , cloudFoundryOptions ) ;
138- } ) ;
139- return builder ;
140- }
125+ => builder . AddCloudFoundryOpenIdConnect ( authenticationScheme , CloudFoundryDefaults . DisplayName , config , ( _ , _ ) => { } ) ;
141126
142127 /// <summary>
143128 /// Adds OpenID Connect middleware and configuration for using UAA or Pivotal SSO for user authentication
@@ -213,19 +198,7 @@ public static AuthenticationBuilder AddCloudFoundryJwtBearer(this Authentication
213198 /// <param name="config">Your application configuration. Be sure to include the <see cref="CloudFoundryConfigurationProvider"/></param>
214199 /// <returns><see cref="AuthenticationBuilder"/> configured to use JWT Bearer tokens from UAA or Pivotal SSO</returns>
215200 public static AuthenticationBuilder AddCloudFoundryJwtBearer ( this AuthenticationBuilder builder , string authenticationScheme , string displayName , IConfiguration config )
216- {
217- builder . AddJwtBearer ( authenticationScheme , displayName , ( options ) =>
218- {
219- var cloudFoundryOptions = new CloudFoundryJwtBearerOptions ( ) ;
220- var securitySection = config . GetSection ( CloudFoundryDefaults . SECURITY_CLIENT_SECTION_PREFIX ) ;
221- securitySection . Bind ( cloudFoundryOptions ) ;
222- cloudFoundryOptions . SetEndpoints ( GetAuthDomain ( securitySection ) ) ;
223-
224- var info = config . GetSingletonServiceInfo < SsoServiceInfo > ( ) ;
225- CloudFoundryJwtBearerConfigurer . Configure ( info , options , cloudFoundryOptions ) ;
226- } ) ;
227- return builder ;
228- }
201+ => builder . AddCloudFoundryJwtBearer ( authenticationScheme , JwtBearerDefaults . AuthenticationScheme , config , ( _ , _ ) => { } ) ;
229202
230203 /// <summary>
231204 /// Adds JWT middleware and configuration for using UAA or Pivotal SSO for bearer token authentication
@@ -259,9 +232,17 @@ public static AuthenticationBuilder AddCloudFoundryJwtBearer(this Authentication
259232 /// <returns><see cref="AuthenticationBuilder"/> configured to use JWT Bearer tokens from UAA or Pivotal SSO</returns>
260233 public static AuthenticationBuilder AddCloudFoundryJwtBearer ( this AuthenticationBuilder builder , string authenticationScheme , string displayName , IConfiguration config , Action < JwtBearerOptions , IConfiguration > configurer )
261234 {
262- builder . AddJwtBearer ( authenticationScheme , displayName , ( jwtoptions ) =>
235+ builder . AddJwtBearer ( authenticationScheme , displayName , jwtBearerOptions =>
263236 {
264- configurer ( jwtoptions , config ) ;
237+ var cloudFoundryOptions = new CloudFoundryJwtBearerOptions ( ) ;
238+ var securitySection = config . GetSection ( CloudFoundryDefaults . SECURITY_CLIENT_SECTION_PREFIX ) ;
239+ securitySection . Bind ( cloudFoundryOptions ) ;
240+ cloudFoundryOptions . SetEndpoints ( GetAuthDomain ( securitySection ) ) ;
241+
242+ var info = config . GetSingletonServiceInfo < SsoServiceInfo > ( ) ;
243+ CloudFoundryJwtBearerConfigurer . Configure ( info , jwtBearerOptions , cloudFoundryOptions ) ;
244+
245+ configurer ( jwtBearerOptions , config ) ;
265246 } ) ;
266247 return builder ;
267248 }
0 commit comments