@@ -46,18 +46,7 @@ public static AuthenticationBuilder AddCloudFoundryOAuth(this AuthenticationBuil
46
46
/// <param name="config">Your application configuration. Be sure to include the <see cref="CloudFoundryConfigurationProvider"/></param>
47
47
/// <returns><see cref="AuthenticationBuilder"/> configured to use OAuth with UAA or Pivotal SSO</returns>
48
48
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 , ( _ , _ ) => { } ) ;
61
50
62
51
/// <summary>
63
52
/// Adds OAuth middleware and configuration for using UAA or Pivotal SSO for user authentication
@@ -93,6 +82,13 @@ public static AuthenticationBuilder AddCloudFoundryOAuth(this AuthenticationBuil
93
82
{
94
83
builder . AddOAuth < CloudFoundryOAuthOptions , CloudFoundryOAuthHandler > ( authenticationScheme , displayName , ( options ) =>
95
84
{
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
+
96
92
configurer ( options , config ) ;
97
93
} ) ;
98
94
return builder ;
@@ -126,18 +122,7 @@ public static AuthenticationBuilder AddCloudFoundryOpenIdConnect(this Authentica
126
122
/// <param name="config">Your application configuration. Be sure to include the <see cref="CloudFoundryConfigurationProvider"/></param>
127
123
/// <returns><see cref="AuthenticationBuilder"/> configured to use OpenID Connect with UAA or Pivotal SSO</returns>
128
124
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 , ( _ , _ ) => { } ) ;
141
126
142
127
/// <summary>
143
128
/// 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
213
198
/// <param name="config">Your application configuration. Be sure to include the <see cref="CloudFoundryConfigurationProvider"/></param>
214
199
/// <returns><see cref="AuthenticationBuilder"/> configured to use JWT Bearer tokens from UAA or Pivotal SSO</returns>
215
200
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 , ( _ , _ ) => { } ) ;
229
202
230
203
/// <summary>
231
204
/// 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
259
232
/// <returns><see cref="AuthenticationBuilder"/> configured to use JWT Bearer tokens from UAA or Pivotal SSO</returns>
260
233
public static AuthenticationBuilder AddCloudFoundryJwtBearer ( this AuthenticationBuilder builder , string authenticationScheme , string displayName , IConfiguration config , Action < JwtBearerOptions , IConfiguration > configurer )
261
234
{
262
- builder . AddJwtBearer ( authenticationScheme , displayName , ( jwtoptions ) =>
235
+ builder . AddJwtBearer ( authenticationScheme , displayName , jwtBearerOptions =>
263
236
{
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 ) ;
265
246
} ) ;
266
247
return builder ;
267
248
}
0 commit comments