All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.shawven.security.browser.BrowserAuthorizationConfigureProvider Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package com.github.shawven.security.browser;

import com.github.shawven.security.authorization.AuthorizationConfigureProvider;
import com.github.shawven.security.browser.config.BrowserConfiguration;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;

import java.util.Arrays;

/**
 * @author Shoven
 * @date 2019-08-20
 */
public class BrowserAuthorizationConfigureProvider implements AuthorizationConfigureProvider {

    private BrowserConfiguration browserConfiguration;

    public BrowserAuthorizationConfigureProvider(BrowserConfiguration browserConfiguration) {
        this.browserConfiguration = browserConfiguration;
    }

    @Override
    public boolean config(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry config) {
        String[] urls = {
                browserConfiguration.getSignInUrl(),
                browserConfiguration.getSignUpUrl(),
                browserConfiguration.getSession().getSessionInvalidUrl(),
                browserConfiguration.getSignOutSuccessUrl()
        };
        config.antMatchers(Arrays.stream(urls).filter(StringUtils::isNotBlank).toArray(String[]::new)).permitAll();

        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy