Skip to content

Support Optional<Principal> argument in @MessageMapping #23612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

KateVasovski
Copy link
Contributor

Add method argument resolver to Optional

@MessageMapping can use Optional as a method argument, which allows to work with or without authentication and to avoid error message org.springframework.messaging.simp.annotation.support.MissingSessionUserException: No "user" header in message

Add method argument resolver to Optional<Principal>

@MessageMapping can use Optional<Principal> as a  method argument, which allows to work with or without authentication and to avoid error message org.springframework.messaging.simp.annotation.support.MissingSessionUserException: No "user" header in message
@pivotal-issuemaster
Copy link

@KateVasovski Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 9, 2019
@pivotal-issuemaster
Copy link

@KateVasovski Thank you for signing the Contributor License Agreement!

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Sep 9, 2019

Thanks for the PR. I think this should be done in PrincipalMethodArgumentResolver instead of in an entirely new resolver. The MethodParameter has support for checking the parameter type in an Optional argument, like it is done here.

@rstoyanchev rstoyanchev self-assigned this Oct 15, 2019
@rstoyanchev rstoyanchev added in: messaging Issues in messaging modules (jms, messaging) in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 15, 2019
@rstoyanchev rstoyanchev added this to the 5.2.1 milestone Oct 15, 2019
@rstoyanchev rstoyanchev changed the title Create OptionalPrincipalMethodArgumentResolver Support Optional<Principal> argument in @MessageMapping Oct 23, 2019
rstoyanchev added a commit that referenced this pull request Oct 23, 2019
@rstoyanchev
Copy link
Contributor

This has been merged. I've squashed the commits into one. There is no reason for the prior incarnation to remain in history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants