@Override protected void configure(HttpSecurity http) throws Exception { http .csrf() .disable() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .requestCache() .disable() .antMatcher("/monitoring/**") .authorizeRequests() .requestMatchers(new RequestHeaderRequestMatcher("x-forwarded-proto", "https")) .hasAnyRole(ROLE_ADMIN) .and() .httpBasic(); }
public HeaderAuthenticationFilter(String headerName, AuthenticationManager authenticationManager) { Assert.hasText(headerName, "headerName cannot be null or empty."); Assert.notNull("AuthenticationManager is required."); this.headerName = headerName; this.requiresAuthenticationRequestMatcher = new RequestHeaderRequestMatcher(headerName, null); this.authenticationManager = authenticationManager; }
public DelegatingAuthenticationEntryPoint getDelegatingAuthenticationEntryPoint() { LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPointMap = new LinkedHashMap<>(); entryPointMap.put(new RequestHeaderRequestMatcher("User-Agent", "Mozilla"), atlasAuthenticationEntryPoint); DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(entryPointMap); entryPoint.setDefaultEntryPoint(getAuthenticationEntryPoint()); return entryPoint; }
@Bean @Autowired public DelegatingAuthenticationEntryPoint delegatingAuthenticationEntryPoint(BasicAuthenticationEntryPoint basic, LoginUrlAuthenticationEntryPoint login) { LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>(); entryPoints.put(new RequestHeaderRequestMatcher("Content-Type", "application/json"), basic); entryPoints.put(new NegatedRequestMatcher(new RequestContainingAcceptTextHeaderRequestMatcher()), basic); DelegatingAuthenticationEntryPoint delegate = new DelegatingAuthenticationEntryPoint(entryPoints); delegate.setDefaultEntryPoint(login); return delegate; }
@Bean @Qualifier("authorizationHeaderRequestMatcher") public RequestMatcher authorizationHeaderRequestMatcher() { return new RequestHeaderRequestMatcher("Authorization"); }
/** Creates a new AFT Token Authentication Filter with the default request matcher * */ public AFTTokenAuthenticationFilter() { super(new RequestHeaderRequestMatcher(AFTAuthentication.AFT_SESSION_TOKEN_HEADER)); }