Using .jsp to create a simple login functionality with oauth 2.0
I’m trying to load a navbar from another file into my login page, using jsp files and a javascript function:
<script>
$(document).ready(function () {
$("#navbar").load("navbar.jsp");
console.log("testing testing");
});
</script>
This creates the typical “Login with OAuth 2.0” in my navbar. I’ve changed my Antmatchers to accept ‘navbar.jsp’ as well.
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.antMatcher("/**")
.authorizeRequests() //problem in antmatchers whenever it sends me to sign in w google randomly //added after example:
.antMatchers("/", "views/navbar","/Login", "/Register", "/resources/", "/login/database", "/example/**","/public/**", "/resources/**","/resources/static/**")
.permitAll()
.antMatchers("/**.js").permitAll() //added this for navbar, not sure if works yet
.anyRequest()
.authenticated()
.and()
.oauth2Login()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/");
}
}
I’ve been researching for a while and cannot seem to find what I’m missing. Anything helps, thanks!