Authentication with OAuth and in memory in Spring Boot

Viewed 121

I have a Spring Boot application with Github login using OAuth 2.0 .I followed the steps given here: https://spring.io/guides/tutorials/spring-boot-oauth2/

My web page is a bit more complicated with header,main and footer frames.The issue is when I login successfully, I get redirected randomly to either the header.html,main.html or footer.html page.Instead I want to be redirected to the index.html which is my actual home page and displays all 3 frames correctly. How do I achieve this ?

The relevant code snippet:

index.html

...

<iframe src="./header.html" name="TradeFrameTop" height="90" width="100%" scrolling="no" style="border:none;"></iframe>
<iframe src="./contentHome.html" name="TradeMainContent" height="700" width="100%" scrolling="no" style="border:none;"></iframe>
<iframe src="./footer.html" name="TradeFrameBottom" height="58" width="100%" scrolling="no" style="border:none;"></iframe>

Application.java

...

@Override
protected void configure(HttpSecurity http) throws Exception{
    http
        .headers().frameOptions().sameOrigin()
        .and()
        .authorizeRequests(a -> a
            .antMatchers("/","/error","/webjars/**").permitAll()
            .anyRequest().authenticated()
        )
        .exceptionHandling(e -> e
            .authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
        )
        .csrf(c -> c
            .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
        )
        .logout(l -> l
            .logoutSuccessUrl("/").permitAll()
        )
        .oauth2Login();


} 

Also, is there a way to have both OAuth based and in-memory authentication in Spring Boot?How do I assign roles and authorities for these 2 pathways separately ?

0 Answers
Related