spring oauth2 disabled form login -
i use oauth2 in spring. however, form login not available more. urls ,"/j_spring_login" , "/j_spring_login_check" not available.
springmvc.xml:
<!-- 自动扫描的包名 --> <context:component-scan base-package="com.sdp.hibernate.model.,com.sdp.hibernate.dao.,com.sdp.controller.,com.sdp.jsoncontroller."></context:component-scan> <!-- 默认的注解映射的支持 --> <mvc:annotation-driven /> <!-- 视图解释类 <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/jsp/"/> <property name="suffix" value=".jsp"/> <property name="viewclass" value="org.springframework.web.servlet.view.jstlview" /> </bean> --> <!-- 拦截器 <mvc:interceptors> <bean class="com.sdp.inteceptor.myinteceptor" /> </mvc:interceptors> --> <!-- 对静态资源文件的访问 方案一 (二选一) <mvc:default-servlet-handler/> --> <!-- 对静态资源文件的访问 方案二 (二选一) --> <mvc:resources mapping="/img/**" location="/img/" cache-period="31556926" /> <mvc:resources mapping="/js/**" location="/js/" cache-period="31556926" /> <mvc:resources mapping="/css/**" location="/css/" cache-period="31556926" /> <bean id="datasource" class="org.apache.commons.dbcp2.basicdatasource" destroy-method="close"> <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url" value="jdbc:mysql://localhost:3306/test?useunicode=true&characterencoding=utf-8" /> <property name="username" value="root" /> <property name="password" value="dangerous" /> <property name="maxidle" value="30" /> <property name="defaultautocommit" value="true" /> <property name="removeabandonedtimeout" value="60" /> </bean> <!-- hibernate配置 --> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="configlocation" value="classpath:hibernate.cfg.xml" /> <property name="packagestoscan"> <list> <value>com.sdp.hibernate.model</value> </list> </property> </bean> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <tx:annotation-driven transaction-manager="transactionmanager" /> <bean id="viewresolver" class="org.springframework.web.servlet.view.velocity.velocityviewresolver"> <property name="cache" value="true"></property> <property name="suffix" value=".html" /> <property name="contenttype" value="text/html; charset=utf-8" /> </bean> <bean id="velocityconfig" class="org.springframework.web.servlet.view.velocity.velocityconfigurer"> <property name="resourceloaderpath" value="/templates/" /> <!-- <property name="configlocation" value="classpath:velocity.properties"/> --> <property name="velocityproperties"> <props> <prop key="output.encoding">utf-8</prop> <prop key="input.encoding">utf-8</prop> </props> </property> </bean> <!-- oauth --> <import resource="spring-servlet.xml" />
here spring-servlet.xml:
<bean id="clientauthenticationentrypoint" class="org.springframework.security.oauth2.provider.error.oauth2authenticationentrypoint"> <!-- <property name="realmname" value="springsec/client" /> --> </bean> <bean id="oauthaccessdeniedhandler" class="org.springframework.security.oauth2.provider.error.oauth2accessdeniedhandler"> </bean> <bean id="loginurlauthenticationentrypoint" class="org.springframework.security.web.authentication.loginurlauthenticationentrypoint"> <property name="loginformurl" value="/login.htm"></property> </bean> <bean id="oauthuserapprovalhandler" class="org.springframework.security.oauth2.provider.approval.defaultuserapprovalhandler"> </bean> <http pattern="/oauth/**" create-session="stateless" authentication-manager-ref="clientauthenticationmanager" xmlns="http://www.springframework.org/schema/security" auto-config="true"> <anonymous enabled="false"/> <http-basic entry-point-ref="clientauthenticationentrypoint"/> <access-denied-handler ref="oauthaccessdeniedhandler"/> </http> <!-- <http pattern="/v1/*" create-session="never" entry-point-ref="oauthauthenticationentrypoint" xmlns="http://www.springframework.org/schema/security"> <custom-filter ref="resourceserverfilter" before="pre_auth_filter"/> <access-denied-handler ref="oauthaccessdeniedhandler"/> </http> --> <http pattern="/v1/**" create-session="never" entry-point-ref="oauthauthenticationentrypoint" access-decision-manager-ref="accessdecisionmanager" xmlns="http://www.springframework.org/schema/security"> <intercept-url pattern='/v1/**' access="role_user"/> <intercept-url pattern='/v1/protected/**' access="is_authenticated_fully"/> <custom-filter ref="resourceserverfilter" before="pre_auth_filter"/> <access-denied-handler ref="oauthaccessdeniedhandler"/> </http> <http pattern="/resources/**" auto-config="true" xmlns="http://www.springframework.org/schema/security"> <intercept-url pattern='/resources/**' access="role_user"/> </http> <bean id="clientcredentialstokenendpointfilter" class="org.springframework.security.oauth2.provider.client.clientcredentialstokenendpointfilter"> <property name="authenticationmanager" ref="clientauthenticationmanager"/> </bean> <authentication-manager id="clientauthenticationmanager" xmlns="http://www.springframework.org/schema/security"> <authentication-provider user-service-ref="client-details-user-service"/> </authentication-manager> <bean id="client-details-user-service" class="org.springframework.security.oauth2.provider.client.clientdetailsuserdetailsservice"> <constructor-arg ref="client-details-service" /> </bean> <oauth:client-details-service id="client-details-service"> <!-- allow access test clients --> <oauth:client client-id="353b302c44574f565045687e534e7d6a" secret="286924697e615a672a646a493545646c" authorized-grant-types="password,refresh_token" authorities="role_user" access-token-validity="30000" autoapprove = "true" refresh-token-validity="30000" scope="read, write" /> <!-- web application clients --> <oauth:client client-id="7b5a38705d7b3562655925406a652e32" secret="655f523128212d6e70634446224c2a48" authorized-grant-types="password,refresh_token" authorities="role_web" access-token-validity="30000" refresh-token-validity="30000" /> <!-- ios clients --> <oauth:client client-id="5e572e694e4d61763b567059273a4d3d" secret="316457735c4055642744596b302e2151" authorized-grant-types="password,refresh_token" authorities="role_ios" access-token-validity="30000" refresh-token-validity="30000" /> <!-- android clients --> <oauth:client client-id="302a7d556175264c7e5b326827497349" secret="4770414c283a20347c7b553650425773" authorized-grant-types="password,refresh_token" authorities="role_android" access-token-validity="30000" refresh-token-validity="30000" /> </oauth:client-details-service> <bean id="passwordencoder" class="org.springframework.security.crypto.password.standardpasswordencoder"/> <authentication-manager alias="authenticationmanager" xmlns="http://www.springframework.org/schema/security"> <!-- <authentication-provider user-service-ref="clientdetailsuserservice" /> --> <authentication-provider> <jdbc-user-service data-source-ref="datasource"/> <!-- <user-service id="userdetailsservice"> <user name="marissa" password="koala" authorities="role_test" /> <user name="paul" password="emu" authorities="role_guest" /> </user-service> --> </authentication-provider> </authentication-manager> <!-- used persistenceof tokens (currently in memory implementation) --> <bean id="tokenstore" class="org.springframework.security.oauth2.provider.token.store.jdbctokenstore"> <constructor-arg ref="datasource"></constructor-arg> </bean> <!-- used create token , and every thing them except persistence reposibility of tokenstore (given here default implementation) --> <bean id="tokenservices" class="org.springframework.security.oauth2.provider.token.defaulttokenservices"> <property name="tokenstore" ref="tokenstore" /> <property name="supportrefreshtoken" value="true" /> <property name="accesstokenvalidityseconds" value="300000"></property> <property name="clientdetailsservice" ref="client-details-service" /> </bean> <oauth:resource-server id="resourceserverfilter" token-services-ref="tokenservices"/> <sec:global-method-security pre-post-annotations="enabled" proxy-target-class="true"> <!--you wire in expression handler @ layer of http filters. see https://jira.springsource.org/browse/sec-1452 --> <sec:expression-handler ref="oauthexpressionhandler" /> </sec:global-method-security> <oauth:expression-handler id="oauthexpressionhandler" /> <oauth:web-expression-handler id="oauthwebexpressionhandler" /> <bean id="accessdecisionmanager" class="org.springframework.security.access.vote.unanimousbased" xmlns="http://www.springframework.org/schema/beans"> <constructor-arg> <list> <bean class="org.springframework.security.oauth2.provider.vote.scopevoter" /> <bean class="org.springframework.security.access.vote.rolevoter" /> <bean class="org.springframework.security.access.vote.authenticatedvoter" /> </list> </constructor-arg> </bean>
thanks help
Comments
Post a Comment