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

(Fixed) Oauth server works yet in endpoint Principal is null [SPR-17132] #21669

Closed
spring-projects-issues opened this issue Aug 6, 2018 · 1 comment
Labels
in: web status: invalid

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 6, 2018

Martijn opened SPR-17132 and commented

I have build a oauth2 server using Spring boot 2.0.8 which uses Spring 5.0.8. The oauth server works and I receive an access token. I can verify that my ResourceServerConfigurerAdapter works because when I access a url with the incorrect access token I get an authentication error so the authentication server + resource server section works. 

I want to create an endpoint that other microservices use call to get the current loggedin user. So I created an endpoint like this:

@GetMapping("/user") 
public Principal user( Principal principal) {
  return auth; 
}

I startup Postman, request a new access token, do a call to /user with the access token supplied as bearer token and start the request. No matter what I do principal is always null. I have even added @AuthenticationPrincipal to the Principal principal argument and yet principal is null. I have also tried the following:

SecurityContextHolder.getContext().getAuthentication()

This also returns null. How is it possible that Principal and getAuthentication() return null?


Affects: 5.0.8

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 6, 2018

Martijn commented

This issue can be deleted. It is an error on my behalf.

@spring-projects-issues spring-projects-issues added type: bug status: invalid in: web and removed type: bug labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web status: invalid
Projects
None yet
Development

No branches or pull requests

1 participant