0

谁能告诉我如何迁移keycloak和spring security。我已经按照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

返回网址: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

4

2 回答 2

0

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

于 2015-12-16T04:08:17.140 回答
0

请在 keycloak 客户端中添加网站来源

于 2019-12-03T10:45:01.470 回答