java - Configure custom server for handling oauth 2.0 in spring -
i totally new spring , oath 2.0. want know /oauth/token
works. in examples shown /oauth/token
in configuration file. suppose have external api handle functionality, example http://mydemo.com/api/oauth/token
. how can able configure in configuration file. below current configuration file.
<?xml version="1.0" encoding="utf-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2" xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <!-- entry url --> <sec:http pattern="/oauth/token" create-session="stateless" entry-point-ref="oauthauthenticationentrypoint" authentication-manager-ref="authenticationmanager"> <sec:intercept-url pattern="/oauth/token" access="is_authenticated_fully" /> <sec:anonymous enabled="false" /> <sec:custom-filter ref="clientcredentialstokenendpointfilter" before="basic_auth_filter" /> <sec:access-denied-handler ref="oauthaccessdeniedhandler" /> </sec:http> <sec:http pattern="/oauth/me" create-session="never" entry-point-ref="oauthauthenticationentrypoint"> <sec:anonymous enabled="false" /> <sec:intercept-url pattern="/oauth/me" method="get" access="is_authenticated_fully" /> <sec:custom-filter ref="resourceserverfilter" before="pre_auth_filter" /> <sec:access-denied-handler ref="oauthaccessdeniedhandler" /> </sec:http> <sec:http pattern="/oauth/authorize" create-session="never" entry-point-ref="oauthauthenticationentrypoint"> <sec:anonymous enabled="false" /> <sec:intercept-url pattern="/oauth/authorize" method="get" access="is_authenticated_fully" /> <sec:custom-filter ref="usercredentialstokenendpointfilter" before="basic_auth_filter" /> </sec:http> <!-- end entry url --> <!-- server --> <oauth:authorization-server client-details-service-ref="clientdetails" token-services-ref="tokenservices" authorization-request-manager-ref="secauthorizationrequestmanager" user-approval-handler-ref="sectokenservicesuserapprovalhandler" user-approval-page="forward:/oauth/confirm_access_custom"> <oauth:authorization-code authorization-code-services-ref="jdbcauthorizationcodeservices" /> <oauth:implicit /> <oauth:refresh-token /> <oauth:client-credentials /> </oauth:authorization-server> <!-- resource --> <oauth:resource-server id="resourceserverfilter" resource-id="springsec" token-services-ref="tokenservices" /> <bean id="oauthauthenticationentrypoint" class="org.springframework.security.oauth2.provider.error.oauth2authenticationentrypoint"> </bean> <bean id="oauthaccessdeniedhandler" class="org.springframework.security.oauth2.provider.error.oauth2accessdeniedhandler"> </bean> <bean id="clientcredentialstokenendpointfilter" class="it.oauth.oauthsec.security.secclientcredentialtoken"> <property name="authenticationmanager" ref="authenticationmanager" /> <property name="clientdetails" ref="clientdetails" /> </bean> <bean id="usercredentialstokenendpointfilter" class="it.oauth.oauthsec.security.secusercredential"> <property name="authenticationmanager" ref="authenticationmanager" /> </bean> <sec:authentication-manager alias="authenticationmanager"> <sec:authentication-provider user-service-ref="clientdetailsuserservice" /> </sec:authentication-manager> <bean id="clientdetailsuserservice" class="org.springframework.security.oauth2.provider.client.clientdetailsuserdetailsservice"> <constructor-arg ref="clientdetails" /> </bean> <bean id="clientdetails" class="it.oauth.oauthsec.security.secclientdetailsservice"> <property name="id" value="test" /> <property name="secretkey" value="mycompanykey" /> </bean> <bean id="sectokenservicesuserapprovalhandler" class="org.springframework.security.oauth2.provider.approval.tokenservicesuserapprovalhandler"> <property name="tokenservices" ref="tokenservices" /> </bean> <bean id="secauthorizationrequestmanager" class="org.springframework.security.oauth2.provider.defaultauthorizationrequestmanager"> <constructor-arg ref="clientdetails" /> </bean> <bean id="tokenservices" class="org.springframework.security.oauth2.provider.token.defaulttokenservices"> <property name="tokenstore" ref="tokenstore" /> <property name="supportrefreshtoken" value="true" /> <property name="clientdetailsservice" ref="clientdetails" /> </bean> <bean id="jdbcauthorizationcodeservices" class="org.springframework.security.oauth2.provider.code.jdbcauthorizationcodeservices"> <constructor-arg ref="jdbctemplate" /> </bean> <bean id="tokenstore" class="org.springframework.security.oauth2.provider.token.jdbctokenstore"> <constructor-arg ref="jdbctemplate" /> </bean> <bean id="jdbctemplate" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url" value="jdbc:mysql://localhost:3306/oauthdb" /> <property name="username" value="root" /> <property name="password" value="" /> </bean> <!-- end persistence layer --> <!-- modelviewcontroller--> <mvc:annotation-driven /> <mvc:default-servlet-handler /> <context:annotation-config /> <context:component-scan base-package="it.oauth.oauthsec.controller" /> <bean class="org.springframework.web.servlet.view.contentnegotiatingviewresolver"> <property name="mediatypes"> <map> <entry key="htm" value="text/htm" /> <entry key="html" value="text/html" /> <entry key="json" value="application/json" /> </map> </property> <property name="viewresolvers"> <list> <bean class="org.springframework.web.servlet.view.beannameviewresolver" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </list> </property> <property name="defaultviews"> <list> <bean class="org.springframework.web.servlet.view.json.mappingjacksonjsonview" /> </list> </property> </bean>
Comments
Post a Comment