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

Issue when accessing /user #130

Open
NaegelCy opened this issue Feb 5, 2021 · 4 comments
Open

Issue when accessing /user #130

NaegelCy opened this issue Feb 5, 2021 · 4 comments
Assignees

Comments

@NaegelCy
Copy link

NaegelCy commented Feb 5, 2021

Hi folks,

I have followed the tutorial step by step and it is really instructive.
However I have 2 concerns :

  1. Is bootstrap and javascript really working as expected? My home page is not displayed beautifully as it should.
  2. More problematic : I am get a 401 http error in Chrome Dev Tools once I authenticated with /user running in the Javascript. I am stuck. Any help would be appreciated to move forward. I mean has someone faced the same?

missing css
http 401 error
Best regards,

Cyril

@marc28
Copy link

marc28 commented Mar 1, 2021

Same Issue on point 2 regarding the '/user'

@ketanhdoshi
Copy link

ketanhdoshi commented Mar 2, 2021

Facing exactly the same two issues as @NaegelCy.

Thirdly, when I comment out the .exceptionHandling lines and add

.antMatchers("/user").permitAll()
// .exceptionHandling()
//                .authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))

it reaches the /user endpoint below, but principal is null, even though I have authenticated via Oauth.

	public Map<String, Object> user(@AuthenticationPrincipal OAuth2User principal) {
		return Collections.singletonMap("name", principal.getAttribute("name"));
	}

@nitinnsfto
Copy link

for me it is working fine for github but for google the authentication is not working. Here are the steps to reduce

  1. Setup the client id and client secret in google OAuth2
  2. Configure the client id and client secret in application.yml
  3. Click on With Google: click here in index.html
  4. I am taken to the google sign in page
  5. Once I sign in I see the cookies set in the redirect to http://localhost:8080/login?error which returns with a 401 response.

is it working for anyone for google OAuth2 server ?

@nayunfeng
Copy link

Issue on point 2 regarding the '/user',because below the javascript run with index.html load

    <script type="text/javascript">
          $.get("/user", function(data) {
            $("#user").html(data.name);
            $(".unauthenticated").hide()
            $(".authenticated").show()
          });
        </script>

And for backend server config, endpoint '/user' not in permit list, then return http status 401

	http
	.authorizeRequests(a -> a
		.antMatchers("/", "/error", "/webjars/**", "/oauth2/**").permitAll()
		.anyRequest().authenticated()
	)
	.exceptionHandling(e -> e
		.authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
	)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants