Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
0da0bff3
Commit
0da0bff3
authored
Jul 24, 2019
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17497 from nosan
* pr/17497: Trim OAuth2 provider property whitespace Closes gh-17497
parents
fb1dd8fe
efce9388
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
OAuth2ClientPropertiesRegistrationAdapter.java
...th2/client/OAuth2ClientPropertiesRegistrationAdapter.java
+3
-2
OAuth2ClientPropertiesRegistrationAdapterTests.java
...lient/OAuth2ClientPropertiesRegistrationAdapterTests.java
+25
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java
View file @
0da0bff3
...
...
@@ -56,9 +56,10 @@ public final class OAuth2ClientPropertiesRegistrationAdapter {
private
static
ClientRegistration
getClientRegistration
(
String
registrationId
,
OAuth2ClientProperties
.
Registration
properties
,
Map
<
String
,
Provider
>
providers
)
{
Builder
builder
=
getBuilderFromIssuerIfPossible
(
registrationId
,
properties
.
getProvider
(),
providers
);
String
provider
=
StringUtils
.
trimWhitespace
(
properties
.
getProvider
());
Builder
builder
=
getBuilderFromIssuerIfPossible
(
registrationId
,
provider
,
providers
);
if
(
builder
==
null
)
{
builder
=
getBuilder
(
registrationId
,
pro
perties
.
getProvider
()
,
providers
);
builder
=
getBuilder
(
registrationId
,
pro
vider
,
providers
);
}
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
map
.
from
(
properties:
:
getClientId
).
to
(
builder:
:
clientId
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapterTests.java
View file @
0da0bff3
...
...
@@ -251,6 +251,31 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
assertThat
(
userInfoEndpoint
.
getUserNameAttributeName
()).
isEqualTo
(
"sub"
);
}
@Test
public
void
getClientRegistrationsWhenRegistrationProviderPropertyShouldBeTrimmed
()
{
OAuth2ClientProperties
properties
=
new
OAuth2ClientProperties
();
OAuth2ClientProperties
.
Registration
registration
=
createRegistration
(
" provider "
);
Provider
provider
=
createProvider
();
properties
.
getProvider
().
put
(
"provider"
,
provider
);
properties
.
getRegistration
().
put
(
"registration"
,
registration
);
assertThat
(
OAuth2ClientPropertiesRegistrationAdapter
.
getClientRegistrations
(
properties
)).
isNotEmpty
();
}
@Test
public
void
getClientRegistrationsWhenRegistrationProviderPropertyWithIssuerShouldBeTrimmed
()
throws
Exception
{
this
.
server
=
new
MockWebServer
();
this
.
server
.
start
();
String
issuer
=
this
.
server
.
url
(
""
).
toString
();
setupMockResponse
(
issuer
);
OAuth2ClientProperties
properties
=
new
OAuth2ClientProperties
();
OAuth2ClientProperties
.
Registration
registration
=
createRegistration
(
" provider "
);
Provider
provider
=
createProvider
();
provider
.
setIssuerUri
(
issuer
);
properties
.
getProvider
().
put
(
"provider"
,
provider
);
properties
.
getRegistration
().
put
(
"registration"
,
registration
);
assertThat
(
OAuth2ClientPropertiesRegistrationAdapter
.
getClientRegistrations
(
properties
)).
isNotEmpty
();
}
private
Provider
createProvider
()
{
Provider
provider
=
new
Provider
();
provider
.
setAuthorizationUri
(
"https://example.com/auth"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment