Search in sources :

Example 1 with FidoServerAttestationResultEndpointFilter

use of com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAttestationResultEndpointFilter in project webauthn4j-spring-security by webauthn4j.

the class WebSecurityConfig method configure.

/**
 * Configure SecurityFilterChain
 */
@Override
protected void configure(HttpSecurity http) throws Exception {
    // WebAuthn Config
    http.apply(WebAuthnLoginConfigurer.webAuthnLogin()).attestationOptionsEndpoint().rp().name("WebAuthn4J Spring Security Sample").and().pubKeyCredParams(new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256), new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.RS1)).extensions().entry("example.extension", "test").and().assertionOptionsEndpoint().extensions().entry("example.extension", "test").and();
    FidoServerAttestationOptionsEndpointFilter fidoServerAttestationOptionsEndpointFilter = new FidoServerAttestationOptionsEndpointFilter(objectConverter, attestationOptionsProvider, challengeRepository);
    FidoServerAttestationResultEndpointFilter fidoServerAttestationResultEndpointFilter = new FidoServerAttestationResultEndpointFilter(objectConverter, userDetailsManager, webAuthnAuthenticatorManager, webAuthnRegistrationRequestValidator);
    fidoServerAttestationResultEndpointFilter.setUsernameNotFoundHandler(new SampleUsernameNotFoundHandler(userDetailsManager));
    FidoServerAssertionOptionsEndpointFilter fidoServerAssertionOptionsEndpointFilter = new FidoServerAssertionOptionsEndpointFilter(objectConverter, assertionOptionsProvider, challengeRepository);
    FidoServerAssertionResultEndpointFilter fidoServerAssertionResultEndpointFilter = new FidoServerAssertionResultEndpointFilter(objectConverter, serverPropertyProvider);
    fidoServerAssertionResultEndpointFilter.setAuthenticationManager(authenticationManagerBean());
    http.addFilterAfter(fidoServerAttestationOptionsEndpointFilter, SessionManagementFilter.class);
    http.addFilterAfter(fidoServerAttestationResultEndpointFilter, SessionManagementFilter.class);
    http.addFilterAfter(fidoServerAssertionOptionsEndpointFilter, SessionManagementFilter.class);
    http.addFilterAfter(fidoServerAssertionResultEndpointFilter, SessionManagementFilter.class);
    // Authorization
    http.authorizeRequests().mvcMatchers("/").permitAll().mvcMatchers("/api/auth/status").permitAll().mvcMatchers(HttpMethod.GET, "/login").permitAll().mvcMatchers(HttpMethod.POST, "/api/profile").permitAll().mvcMatchers("/health/**").permitAll().mvcMatchers("/info/**").permitAll().mvcMatchers("/h2-console/**").denyAll().mvcMatchers("/api/admin/**").hasRole(ADMIN_ROLE).anyRequest().fullyAuthenticated();
    // TODO:
    http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
    http.csrf().ignoringAntMatchers("/webauthn/**");
}
Also used : FidoServerAttestationOptionsEndpointFilter(com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAttestationOptionsEndpointFilter) PublicKeyCredentialParameters(com.webauthn4j.data.PublicKeyCredentialParameters) FidoServerAttestationResultEndpointFilter(com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAttestationResultEndpointFilter) FidoServerAssertionOptionsEndpointFilter(com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAssertionOptionsEndpointFilter) SampleUsernameNotFoundHandler(com.webauthn4j.springframework.security.webauthn.sample.app.security.SampleUsernameNotFoundHandler) FidoServerAssertionResultEndpointFilter(com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAssertionResultEndpointFilter)

Aggregations

PublicKeyCredentialParameters (com.webauthn4j.data.PublicKeyCredentialParameters)1 FidoServerAssertionOptionsEndpointFilter (com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAssertionOptionsEndpointFilter)1 FidoServerAssertionResultEndpointFilter (com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAssertionResultEndpointFilter)1 FidoServerAttestationOptionsEndpointFilter (com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAttestationOptionsEndpointFilter)1 FidoServerAttestationResultEndpointFilter (com.webauthn4j.springframework.security.fido.server.endpoint.FidoServerAttestationResultEndpointFilter)1 SampleUsernameNotFoundHandler (com.webauthn4j.springframework.security.webauthn.sample.app.security.SampleUsernameNotFoundHandler)1