如何在 webssoprofileoption 中将 forceAuthn 设置为 true?

How to set forceAuthn as true in webssoprofileoption?

我是 Spring-boot 的新手,刚刚通过 Spring Security 和 Okta 的 SAML 身份验证按照本教程进行操作。在使用 WebSecurityConfigurerAdapter 配置时,我无法在 WebSSOProfileOptions 下设置 ForceAuthN。

有人能给我举个例子或给我指明正确的方向吗?

我尝试了下面的代码但是出现类型错误,请帮助解决它

public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

 @Override
    protected void configure(final HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .antMatchers("/saml*").permitAll()
                .anyRequest().authenticated()
                .and() 
            .apply(saml())
                .serviceProvider()
                    .keyStore()
                        .storeFilePath("saml/keystore.jks")
                        .password(this.password)
                        .keyname(this.keyAlias)
                        .keyPassword(this.password)
                    .and()
                    .protocol("https")
                    .hostname(String.format("%s:%s", "localhost", this.port))
                    .basePath("/")
                .and()
                .identityProvider()
                    .metadataFilePath(this.metadataUrl)
                .and()
                .WebSSOProfileOptions(getWebSSOProfileOptions());

    }
 @Bean
    public WebSSOProfileOptions getWebSSOProfileOptions() {
        WebSSOProfileOptions profile = new WebSSOProfileOptions();
        profile.setForceAuthN(true);
        return profile;
    }

}

您应该尝试实例化一个 SAMLEntryPoint 并使用您的 WebSSOProfileOptions bean 配置其 defaultProfileOptions 属性。

samlEntryPoint.setDefaultProfileOptions(getWebSSOProfileOptions());