使用apikey保护restapi?

使用apikey保护restapi?,rest,spring-security,spring-oauth2,Rest,Spring Security,Spring Oauth2,我们有一个使用Spring Security保护的Spring web应用程序,一组SOAP API服务使用Spring MVC用于验证用户的相同安全域@org.jboss.ejb3.annotation.SecurityDomain 我们现在正在重构应用程序并创建安全的RESTAPI。 我们认为应遵循以下方法 Spring@RestController方法充当restapi/webservices来替换我们现有的soapis Spring OAuth2保护REST API SpringMVC

我们有一个使用Spring Security保护的Spring web应用程序,一组SOAP API服务使用Spring MVC用于验证用户的相同安全域@org.jboss.ejb3.annotation.SecurityDomain

我们现在正在重构应用程序并创建安全的RESTAPI。 我们认为应遵循以下方法

  • Spring@RestController方法充当restapi/webservices来替换我们现有的soapis
  • Spring OAuth2保护REST API
  • SpringMVC继续使用Spring安全性和wildfly服务器中定义的安全域,在表单登录之后,一旦用户通过javascript/angular js的身份验证,就使用oauth访问令牌来调用受保护的RESTAPI
弹簧配置

要求我们的webservice客户端在请求参数/头中发送凭据以获取访问令牌是否安全?

在服务器会话中保存令牌以在Spring MVC请求的UI中使用它,这是一种很好的方法吗?

<强>我们还要求考虑API密钥来访问其余API。通过使用API键,我们可以获得ejb会话上下文和用户详细信息吗?如果是这样,我们可以在Web部件中使用API密钥和spring安全性吗?

<http pattern="/restapi/**" entry-point-ref="oauthAuthenticationEntryPoint"
    create-session="stateless" xmlns="http://www.springframework.org/schema/security"
    use-expressions="true">
    <anonymous enabled="false" />
    <access-denied-handler ref="oauthAccessDeniedHandler" />
    <intercept-url pattern="/restapi/**" access="isAuthenticated()" />
    <remember-me key="myapp" services-ref="rememberMeServices" />
    <custom-filter ref="jbossSecurityFilter" after="REMEMBER_ME_FILTER" />
    <custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
</http>

<http pattern="/oauth/token" create-session="stateless"
    use-expressions="true" authentication-manager-ref="authenticationManager">
    <intercept-url pattern="/oauth/token" access="isAuthenticated()" />
    <anonymous enabled="false" />
    <custom-filter ref="clientCredentialsTokenEndpointFilter"
        before="BASIC_AUTH_FILTER" />
    <access-denied-handler ref="oauthAccessDeniedHandler" />
    <http-basic entry-point-ref="clientAuthenticationEntryPoint" />
    <remember-me key="myapp" services-ref="rememberMeServices" />
    <custom-filter ref="jbossSecurityFilter" after="REMEMBER_ME_FILTER" />
</http>

<beans:bean id="jaasAuthenticationProvider"     class="org.springframework.security.authentication.jaas.JaasAuthenticationProvider">
              <beans:property name="refreshConfigurationOnStartup" value="false"/> 
              <beans:property name="loginConfig" value="/WEB-INF/login.conf" />
              <beans:property name="loginContextName" value="AppName" />
              <beans:property name="callbackHandlers">
                 <beans:list>
                    <beans:ref bean="jaasNameCallBackHandler" />
                    <beans:bean class="org.springframework.security.authentication.jaas.JaasPasswordCallbackHandler" />
                 </beans:list>
              </beans:property>
              <beans:property name="authorityGranters">
                 <beans:list>
                    <beans:bean class="com.custom.CustomAuthorityGranter" />
                 </beans:list>
              </beans:property>
           </beans:bean>