spring-projects / spring-projects/spring-security

please support the use of resolvable parameters in functional (reactive) Spring MVC endpoints

Open
#16,836 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Spring WebFlux and Spring MVC introduced functional style configuration models for HTTP endpoints in 2017.


    @Bean
    RouterFunction<ServerResponse> myMvcRouterFunction() {
        return route()
                .GET("/**", new HandlerFunction<ServerResponse>() {
                    @Override
                    public ServerResponse handle(ServerRequest request) throws Exception {
                        return ServerResponse.ok().body("hello world");
                    }
                })
                .build();
    }

obviously, you wouldn't normally write that code out long hand. You'd use a lambda.

    @Bean
    RouterFunction<ServerResponse> myMvcRouterFunction() {
        return route()
                .GET("/**",  _  ->  ServerResponse.ok().body("hello world"))
                .build();
    }

That's taken from a Spring MVC application, though it's basically the same in Spring Webflux.

However, as far as I can tell, it's not possible to benefit from the various parameter/return value/argument resolvers for Spring MVC/Spring Webflux controllers in this model. This means things like Spring Security's @RegisteredOAuth2AuthorizedClient OAuth2AuthorizedClient oac are inaccessible.

For at leas the argument / parameter resolvers, it might be nice to provide a singleton.

I am hoping you'd consider exposing those as proxied singletons, sort of like Spring Framework's EntityManager, so that I could inject a singleton bean (OAuth2AuthorizedClient), but behind the scenes it would be scoped to the currently authenticated user. This might even be as simple as a request scoped bean, though I feel (perhaps irrationally) that that's less ideal than a simple facade (or even a proxy) that just sources the right value for the currently authenticated user.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing functional Spring MVC and Spring WebFlux endpoint configuration and how controller parameter and argument resolvers currently work. Compare that behavior with the Spring Security OAuth2 authorized-client example in the issue, then define and validate an API for making resolved values available to functional handlers.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, authentication, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.