4

Spring のセキュリティ構成を xml から Java 構成に変換したいと考えています。ほぼ完了していません。最後の問題は AuthenticationEntryPoint です。HttpSecurity での設定は無視されます。

Spring セキュリティ 3.2.0.M2 を使用しています

SecurityConfig.class の抜粋

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .addFilterAfter(httpPayloadFilter(), ChannelProcessingFilter.class)
            .addFilterAfter(httpRestLoginFilter(), SecurityContextPersistenceFilter.class)
            .authorizeUrls()
                .antMatchers("/**").hasRole("USER")
                .antMatchers("/secure/clientident/**").hasRole("REQUESTVALID")
                .and()
            .httpBasic().authenticationEntryPoint(delegatingAuthenticationEntryPoint());
    }

@Bean
    public DelegatingAuthenticationEntryPoint delegatingAuthenticationEntryPoint() {

        ELRequestMatcher matcher = new ELRequestMatcher("hasHeader('user-agent', 'Mozilla') or " +
                "hasHeader('user-agent', 'Chromium') or " +
                "hasHeader('user-agent', 'Chrome') or " +
                "hasHeader('user-agent', 'Safari')");


        LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> map = 
                new LinkedHashMap<RequestMatcher, AuthenticationEntryPoint>();
        map.put(matcher, new BasicAuthenticationEntryPoint());

        DelegatingAuthenticationEntryPoint delegatingAuthenticationEntryPoint = new DelegatingAuthenticationEntryPoint(map);
        delegatingAuthenticationEntryPoint.setDefaultEntryPoint(new Http403ForbiddenEntryPoint());


        return delegatingAuthenticationEntryPoint;
    }

クライアント側で常に「HTTP 403」(Http403ForbiddenEntryPointを推測)を取得します。また、AuthenticationEntryPoint を委譲せずに簡単な構成を試してみました。

.httpBasic().authenticationEntryPoint(new BasicAuthenticationEntryPoint())

これも機能しません。私が間違っていることを誰かが知っていますか?

追加:
より適切にロックする必要があります。この問題に関する別の投稿を見つけました。
基本認証のみを示すSpring Security Java構成の例が必要
チケットSEC-2198も配置されています。

現在の回避策。

.exceptionHandling()
   .authenticationEntryPoint(delegatingAuthenticationEntryPoint())
   .and()
.httpBasic();
4

0 に答える 0