Skip to content
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

Introduce @CurrentSecurityContext for method arguments #6562

Merged
merged 3 commits into from
Apr 14, 2019

Conversation

clevertension
Copy link
Contributor

it can both support with spring web mvc and reactive web, user can retrieve SecurityContext in controller easily, such as

import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.CurrentSecurityContext;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MySecurityController {
	@RequestMapping("/security-context")
	public String securityContext(@CurrentSecurityContext SecurityContext context) {
		Authentication auth = context.getAuthentication();
		//do with security context and related authentication
		return "security-context";
	}
}

#6546

Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

Thanks, @clevertension! I've left some inline feedback.

Also, I'd like to see if @rwinch has some feedback, too, especially around whether the patterns that are copied from the existing argument resolvers are ones we want to propagate.

@clevertension
Copy link
Contributor Author

@jzheaux thanks very much for your review feedback, i have already fix all the issues that you mentioned, so should i add extra 1 commit, or still keep only one commit by force push here?

@jzheaux
Copy link
Contributor

jzheaux commented Mar 2, 2019

@clevertension Either way. Before we merge, you'll need to force push down to one commit. Some folks like to keep commits separate while the review is going on. For small PRs like this, it doesn't make a big difference.

@clevertension
Copy link
Contributor Author

👍,👍,👍

@jzheaux jzheaux self-assigned this Mar 5, 2019
@jzheaux jzheaux requested a review from rwinch March 5, 2019 05:13
@clevertension
Copy link
Contributor Author

@rwinch , can you spare time to review this PR? thank you very much

@jzheaux jzheaux added status: duplicate A duplicate of another issue New Feature in: web An issue in web modules (web, webmvc) labels Apr 5, 2019
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

@clevertension I took a fresh look at this, and I left a couple more comments inline.

@clevertension clevertension force-pushed the gh_6546 branch 2 times, most recently from 418c898 to de356cd Compare April 9, 2019 07:06
Copy link
Member

@rwinch rwinch left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @clevertension! The changes look good

@jzheaux jzheaux merged commit 22c8f63 into spring-projects:master Apr 14, 2019
@jzheaux
Copy link
Contributor

jzheaux commented Apr 14, 2019

Thanks, @clevertension! This is now merged into master.

@jzheaux jzheaux added this to the 5.2.0.M2 milestone Apr 15, 2019
@rwinch rwinch added the type: enhancement A general enhancement label May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants