Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.

...

  1. Si no existe en nuestro proyecto, crear una clase SecurityConfig.java nueva a partir del código de FundeWebJSSecurityConfig(ubicada en la librería fundewebjs-security).

    Bloque de código
    languagejava
    titleFundeWebJSSecurityConfig
    collapsetrue
    @Log4j2
    @Configuration
    public class FundeWebJSSecurityConfig {
    
    	@Value( "${server.scopes}" )
    	private String[] serverScopes;
    
    	@Value( "${app.server.path}" )
    	private String apiPath;
    
    
    	/**
    	 * Proveedor de gestion de acceoss
    	 */
    	@Bean( name = "fundeWebJsDefaultSecurityFilterChain" )
    	@ConditionalOnExpression( "${fdwjs.starter.security.enable:true}" )
    	public SecurityFilterChain filterChain( HttpSecurity http ) throws Exception {
    
    		log.debug( "Carga SecurityFilterChain desde FundewebJs-Starter" );
    
    		http.requestMatchers().antMatchers( "/public/**" ).and().requestMatchers().antMatchers( apiPath + "/**" ).and()
    		.sessionManagement().sessionCreationPolicy( SessionCreationPolicy.STATELESS )
    		// configuro politica de sesion sin estado
    		.and().cors() // Aniado configuracion CORS por defecto
    		.and().csrf().disable().authorizeRequests().mvcMatchers( apiPath + "/public/**" ).permitAll()
    		.mvcMatchers( apiPath + "/**" ).hasAnyAuthority( serverScopes ).anyRequest().authenticated().and()
    		.addFilterAfter( new FundeWebJSLoggingAuthorizationFilter(), BearerTokenAuthenticationFilter.class )
    		.oauth2ResourceServer()
    		.jwt();
    
    		return http.build();
    	}
    
    }



  2. En el application.properties (de local y de los entornos en Helm Chart), añadir la siguiente property:

...