Skip to content

Instantly share code, notes, and snippets.

@jrgleason
Created October 19, 2024 16:39
Show Gist options
  • Save jrgleason/5a6a4d0e2985253b5a070cc6489d2d92 to your computer and use it in GitHub Desktop.
Save jrgleason/5a6a4d0e2985253b5a070cc6489d2d92 to your computer and use it in GitHub Desktop.
<Auth0Provider
// @ts-ignore
domain={domain}
// @ts-ignore
clientId={clientId}
useRefreshTokens={true}
cacheLocation={"localstorage"}
// TODO: Avoid hardcoding these values
advancedOptions={{defaultScope: 'email'}}
authorizationParams={{
redirect_uri: redirectUrl,
audience: "https://cbusha.com",
defaultScope: "email",
}}
>
<Router>
<CssBaseline/>
<CBusAppBar/>
<main style={{height: "100%"}}>
<Splash/>
</main>
</Router>
</Auth0Provider>
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
.oauth2Login(AbstractHttpConfigurer::disable)
.oauth2ResourceServer(AbstractHttpConfigurer::disable)
.sessionManagement((session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.oauth2ResourceServer((oauth2) -> oauth2
.jwt((jwt) -> jwt.decoder(jwtDecoder()))
)
.authorizeHttpRequests((authz) -> authz
.requestMatchers(
new AntPathRequestMatcher("/actuator/**")
).hasAuthority("SCOPE_read:actuators")
.requestMatchers(
new AntPathRequestMatcher("/customer/**", "POST")
).hasAuthority("SCOPE_user:admin")
.requestMatchers(
new AntPathRequestMatcher("/chat"),
new AntPathRequestMatcher("/chat/**"),
new AntPathRequestMatcher("/app/chat"),
new AntPathRequestMatcher("/app/chat/**"),
new AntPathRequestMatcher("/topic/**"),
new AntPathRequestMatcher("/heartbeat", "GET"),
new AntPathRequestMatcher("/contact"),
new AntPathRequestMatcher("/contact", "POST"),
new AntPathRequestMatcher("/contact/**"),
new AntPathRequestMatcher("/assistant", "GET"),
new AntPathRequestMatcher("/user/stash")
).permitAll()
.requestMatchers(
new AntPathRequestMatcher("/finance")
).hasAuthority("SCOPE_finance")
.anyRequest().authenticated()
);
return http.build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment