Skip to content

Fix Bearer token parsing for multiple spaces - #19512

Open
therepanic wants to merge 1 commit into
spring-projects:mainfrom
therepanic:gh-19500
Open

Fix Bearer token parsing for multiple spaces#19512
therepanic wants to merge 1 commit into
spring-projects:mainfrom
therepanic:gh-19500

Conversation

@therepanic

Copy link
Copy Markdown
Contributor

RFC 6750 allows one or more spaces. This change updates Bearer token parsing accordingly.

Closes: gh-19500

RFC 6750 allows one or more spaces. This change updates Bearer token
parsing accordingly.

Closes: spring-projectsgh-19500

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
private static final String ACCESS_TOKEN_PARAMETER_NAME = "access_token";

private static final Pattern authorizationPattern = Pattern.compile("^Bearer (?<token>[a-zA-Z0-9-._~+/]+=*)$",
private static final Pattern authorizationPattern = Pattern.compile("^Bearer +(?<token>[a-zA-Z0-9-._~+/]+=*)$",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be clearer to use \x20+, since the RFC allows only spaces, but the current change is more minimal and seems like a better fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefaultBearerTokenResolver rejects RFC-legal multi-space Authorization header

2 participants