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

Can you do a demo on custom login page #4

Open
uniquejava opened this issue Feb 28, 2023 · 1 comment
Open

Can you do a demo on custom login page #4

uniquejava opened this issue Feb 28, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@uniquejava
Copy link

Greetings!

With the PKCE edition, I can login with the default login page. but I cannot login when use a custom login page. Would you please do a demo for custom login page. Thanks.

My configuration:

  @Bean
  SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
      http
              .authorizeHttpRequests((authorize) -> authorize
                      .anyRequest().authenticated()
              );

        http.formLogin((formLogin) -> formLogin
                .loginPage("/login")
                .defaultSuccessUrl("http://127.0.0.1:3000", true)
                .permitAll()
        );
      return http.build();

  }

  @Bean
  public WebSecurityCustomizer webSecurityCustomizer() {
      return (web) -> web.debug(false)
              .ignoring()
              .requestMatchers("/webjars/**", "/images/**","/css/**", "/assets/**", "/favicon.ico");
  }

LoginControll.java

@Controller
@Slf4j
public class LoginController {
    @GetMapping(value = "/login")
    public String loginPage(){
        return "login";
    }
}

And I have a custom templates/login.html page!

For frontend, I used vue3 and oidc-client-ts.

import type { UserManagerSettings } from 'oidc-client-ts'
import { UserManager } from 'oidc-client-ts'

// All endpoints => http://corfu-auth:9000/.well-known/openid-configuration
const settings: UserManagerSettings = {
  authority: "http://corfu-auth:9000",
  client_id: 'client',
  redirect_uri: 'http://127.0.0.1:3000/user/signin-callback',
  response_type: 'code',
  scope: "openid profile",
  revokeAccessTokenOnSignout: true,

  // metadata: {
  //   authorization_endpoint: `http://corfu-auth:9000/oauth2/authorize`,
  //   token_endpoint: `http://corfu-auth:9000/oauth2/token`,
  //   end_session_endpoint: `http://corfu-auth:9000/oauth2/revoke`
  // }
}

export const userManager = new UserManager(settings)

export const getUser = ()=>{
  return userManager.getUser()
}

export const login = ()=>{
  return userManager.signinRedirect()
}

export const logout = ()=>{
  return userManager.signoutRedirect()
}

The login from backend works, but It cannot forward me to my frontend after successful login. 😢

@andifalk andifalk added the enhancement New feature or request label May 8, 2023
@andifalk andifalk added this to the Version 1.1.0 milestone May 8, 2023
@andifalk
Copy link
Owner

andifalk commented May 8, 2023

Hi @uniquejava
thanks for your question. I will check if I can provide such a demo.

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

No branches or pull requests

2 participants