-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Abhijit Sarkar opened SPR-15931 and commented
ServerRequest.uri() returns a relative URI that starts with //, thus making it impossible to extract the scheme. The scheme is required when working with OAuth that requires a redirect URL to be sent with the initial request.
Here's a sample OAuth call for Pinterest:
fun redirect(request: ServerRequest): Mono<ServerResponse> =
UriComponentsBuilder.fromUriString("https://api.pinterest.com/oauth/")
.queryParam("response_type", "code")
.queryParam("scope", "read_public,write_public")
.queryParam("state", state)
.queryParam("client_id", clientId)
.queryParam("redirect_uri", request.uri().resolve(URI.create("oauth/token"))
.let { uri -> (uri.scheme ?: "https").let { "$it:$uri" } })
.build()
.toUri()
.also { logger.debug("Making request to: $it.") }
.let { ServerResponse.permanentRedirect(it).build() }
fun accessToken(request: ServerRequest): Mono<ServerResponse> =
request
.also {
logger.debug("Received access token: $it.")
it.queryParam("state")
.filter { it == state }
.flatMap { request.queryParam("code") }
.ifPresent { cache.put("accessToken", it) }
}
.let { ServerResponse.noContent().build() }
Affects: 5.0 RC3
Issue Links:
- WebFlux equivalent of MvcUriComponentsBuilder [SPR-15953] #20505 Introduce WebFluxUriComponentsBuilder
- Introduce ForwardedHeaderFilter for WebFlux [SPR-15954] #20506 Introduce ForwardedHeaderFilter for WebFlux
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement