Keycloak 和 Spring 安全

Keycloak and Spring Security

任何人都可以告诉我如何迁移 keycloak 和 spring 安全性。我已经按照 http://keycloak.github.io/docs/userguide/keycloak-server/html/ch08.html#spring-security-adapter 中的步骤进行操作。但它确实有效。我需要编写自己的提供商吗?

我原来的spring-security.xml

    <beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-4.0.xsd
                        http://www.springframework.org/schema/util 
                        http://www.springframework.org/schema/util/spring-util.xsd
                        http://www.springframework.org/schema/security
                        http://www.springframework.org/schema/security/spring-security-3.2.xsd"
        >

    <http use-expressions="true">
        <intercept-url pattern="/index" access="isAuthenticated()" />
        <intercept-url pattern="/tasks" access="isAuthenticated()" />
        <intercept-url pattern="/dashboard" access="isAuthenticated()" />
        <intercept-url pattern="/resetPassword" access="isAuthenticated()" />
        <intercept-url pattern="/settings/**" access="isAuthenticated()" />
        <intercept-url pattern="/" access="isAuthenticated()" />
        <intercept-url pattern="/sam/**" access="hasRole('mym_security_permission-002')" />
        <intercept-url pattern="/admin/**" access="hasRole('mym_security_permission-005')" />
        <intercept-url pattern="/committee/**" access="isAuthenticated()" />
        <intercept-url pattern="/member/**" access="isAuthenticated()" />
        <intercept-url pattern="/attachment/download/**" access="isAuthenticated()" />

        <!-- access denied page -->
        <access-denied-handler error-page="/403" />

        <form-login 
            login-page="/login"
            login-processing-url="/perform_login"
            authentication-failure-url="/login?error"
            authentication-success-handler-ref="customAuthenticationSuccessHandler"
            username-parameter="username"
            password-parameter="password"
            always-use-default-target="true"
        />
        <!--success-handler-ref="customLogoutSuccessHandler"  -->
        <logout 
            logout-url="/perform_logout"
            delete-cookies="true"
            invalidate-session="true"

        />
        <!-- enable csrf protection -->
        <csrf/>

        <session-management>
            <concurrency-control max-sessions="1" />
        </session-management>
    </http>

    <authentication-manager alias="authenticationManager" erase-credentials="false">
        <authentication-provider ref="customAuthenticationProvider" />
    </authentication-manager>

</beans:beans>

我将此 xml 更改为 keycloak 用户指南提供的 xml。我把 keycloak.json 放在 web-inf.

在我对keycloak进行配置之后。我尝试访问我的页面,然后会出现如下错误页面:

我们很抱歉...

无效参数:redirect_uri

return url:http://localhost:8080/auth/realms/Meeting/protocol/openid-connect/auth?response_type=code&client_id=mym-apps&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2FApp%2Fsso%2Flogin&state=0%2Fd21c7ae9-b041-43e5-8135-8150e9895ee5&login=true

我已经解决了这个问题。我只是将我的“有效重定向 URI”修复为 http://localhost:8080/app/* 和 /app/*

请在keycloak客户端添加web orgins