You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bu...@apache.org on 2015/12/02 12:47:47 UTC

svn commit: r974280 - in /websites/production/cxf/content: cache/docs.pageCache docs/jaxrs-oauth2-assertions.html

Author: buildbot
Date: Wed Dec  2 11:47:47 2015
New Revision: 974280

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html
==============================================================================
--- websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html (original)
+++ websites/production/cxf/content/docs/jaxrs-oauth2-assertions.html Wed Dec  2 11:47:47 2015
@@ -118,30 +118,32 @@ Apache CXF -- JAXRS OAuth2 Assertions
            <!-- Content -->
            <div class="wiki-content">
 <div id="ConfluenceContent"><h1 id="JAXRSOAuth2Assertions-JAXRS:OAuth2Assertions">JAXRS: OAuth2 Assertions</h1><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1449053223153 {padding: 0px;}
-div.rbtoc1449053223153 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1449053223153 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1449053223153">
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-JAXRS:OAuth2Assertions">JAXRS: OAuth2 Assertions</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-Introduction">Introduction</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-Mavendependencies">Maven dependencies</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</a>
+div.rbtoc1449056823368 {padding: 0px;}
+div.rbtoc1449056823368 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1449056823368 li {margin-left: 0px;padding-left: 0px;}
+
+/*]]>*/</style></p><div class="toc-macro rbtoc1449056823368">
+<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-JAXRS:OAuth2Assertions">JAXRS: OAuth2 Assertions</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-Introduction">Introduction</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</a>
+<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-Mavendependencies">Maven dependencies</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-Clientcode">Client code</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService">Access Token Service</a></li></ul>
 </li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AuthenticationToken">Authentication Token</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-ClientCode">Client Code</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.1">Access Token Service</a></li></ul>
 </li><li><a shape="rect" href="#JAXRSOAuth2Assertions-ClientActingonBehalfofItself">Client Acting on Behalf of Itself</a></li></ul>
 </li><li><a shape="rect" href="#JAXRSOAuth2Assertions-JWTBearer">JWT Bearer</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-ClientCode.1">Client Code</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.2">Access Token Service</a></li></ul>
+<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenGrant.1">Access Token Grant</a>
+<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-Clientcode.1">Client code</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.2">Access Token Service</a></li></ul>
+</li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</a>
+<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSOAuth2Assertions-ClientCode.1">Client Code</a></li><li><a shape="rect" href="#JAXRSOAuth2Assertions-AccessTokenService.3">Access Token Service</a></li></ul>
 </li></ul>
 </li></ul>
-</div><h1 id="JAXRSOAuth2Assertions-Introduction">Introduction</h1><p><a shape="rect" class="external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-v2" rel="nofollow">OAuth 2.0</a> supports different types of access token grants. <a shape="rect" class="external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-assertions-10" rel="nofollow">OAuth2 Assertions</a> draft "provides a framework for the use of assertions with OAuth 2.0" and <a shape="rect" class="external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-15" rel="nofollow">SAML2 Bearer Assertion Profiles for OAuth2</a> draft specifically provides for the use of SAML2 Bearer assertions.</p><p>These assertions can be used as token grants, but also, if needed, for getting 3rd party clients authenticated. Note the clients can use assertions as grants but use for example Basic authentication mechanism, or use say an authorization code grant and the assertion to authenticate, and finally, they 
 can use assertions as a grant and as an authentication token.</p><p>Currently CXF supports SAML2 Bearer assertions as grants and authentication tokens.</p><p>See the <a shape="rect" href="jax-rs-oauth2.html">JAX-RS OAuth2</a> page for information about OAuth 2.0 support in CXF. Please also check the <a shape="rect" href="jax-rs-saml.html">JAX-RS SAML</a> page for more information about SAML support.</p><h1 id="JAXRSOAuth2Assertions-Mavendependencies">Maven dependencies</h1><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div><h1 id="JAXRSOAuth2Assertions-Introduction">Introduction</h1><p><a shape="rect" class="external-link" href="https://tools.ietf.org/html/rfc6749" rel="nofollow">OAuth 2.0</a> supports different types of access token grants. The <a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7521" rel="nofollow">OAuth2 Assertions</a> spec "provides a framework for the use of assertions with OAuth 2.0 in the form of a new client authentication mechanism and a new authorization grant type". More specifically, the <a shape="rect" class="external-link" href="https://tools.ietf.org/html/rfc7522" rel="nofollow">SAML2 Bearer Assertion Profiles for OAuth2</a> spec provides for the use of SAML2 Bearer assertions, and the <a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7523" rel="nofollow">JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants</a> spec providers for the use of JWT Bearer tokens.</p><p>These assertions 
 can be used as token grants, but also, if needed, for getting 3rd party clients authenticated. Note the clients can use assertions as grants but use for example Basic authentication mechanism, or use say an authorization code grant and the assertion to authenticate, and finally, they can use assertions as a grant and as an authentication token.</p><p>Currently CXF supports both SAML2 Bearer and JWT Bearer assertions as grants and authentication tokens.</p><p>See the <a shape="rect" href="jax-rs-oauth2.html">JAX-RS OAuth2</a> page for information about OAuth 2.0 support in CXF. Please also check the <a shape="rect" href="jax-rs-saml.html">JAX-RS SAML</a> page for more information about SAML support.</p><p>&#160;</p><h1 id="JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</h1><h2 id="JAXRSOAuth2Assertions-Mavendependencies">Maven dependencies</h2><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;dependency&gt;
   &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
   &lt;artifactId&gt;cxf-rt-rs-security-oauth2-saml&lt;/artifactId&gt;
-  &lt;version&gt;2.7.4&lt;/version&gt;
+  &lt;version&gt;${cxf.version}&lt;/version&gt;
 &lt;/dependency&gt;
 </pre>
-</div></div><h1 id="JAXRSOAuth2Assertions-SAML2Bearer">SAML2 Bearer</h1><h2 id="JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</h2><p><a shape="rect" class="external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-15#section-2.1" rel="nofollow">This section</a> explains how SAML2 Bearer assertions can be used as token grants. The value of grant_type parameter is "urn:ietf:params:oauth:grant-type:saml2-bearer".</p><p>It is really just another grant type, but whose actual value is a SAML assertion. The specification provides an <a shape="rect" class="external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-15#section-4" rel="nofollow">example</a> of how such an assertion may look like.</p><p>The additional restriction is that the assertions have to be encoded using Base64Url encoding. <br clear="none"> Here is how a request may look like:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
  pdl">
+</div></div><h2 id="JAXRSOAuth2Assertions-AccessTokenGrant">Access Token Grant</h2><p><a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7522#section-2.1" rel="nofollow">This section</a> explains how SAML2 Bearer assertions can be used as token grants. The value of grant_type parameter is "urn:ietf:params:oauth:grant-type:saml2-bearer".</p><p>It is really just another grant type, but whose actual value is a SAML assertion. The specification provides an <a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7522#section-4" rel="nofollow">example</a> of how such an assertion may look like.</p><p>The additional restriction is that the assertions have to be encoded using Base64Url encoding. <br clear="none"> Here is how a request may look like:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">POST /token HTTP/1.1
 Content-Type: application/x-www-form-urlencoded
 
@@ -178,7 +180,7 @@ ClientAccessToken at = OAuthClientUtils.
                                                        grant,
                                                        false);
 </pre>
-</div></div><p>The code above prepares an info for a new SAML assertion be self-signed, loading a Crypto instance with crypto <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/alice.properties">properties</a>, and uses SAMLUtils to create and sign the assertion (using Crypto, plus user alias and password). Saml2BearerGrant will get the assertion Base64Url-encoded - unless the assertion has already been encoded with CXF Base64UrlUtility or came encoded from IP - in this case Saml2BearerGrant constructor accepting an 'encoded' property will have to be used, with the value set to "true".</p><p>This is nearly as simple as using other token grants, the step 2 will often me omitted in more involved cases as it will be the job of Identity Providers to issue OAuth2 SAML2 Bearer assertions. Step 2 needs to be done when testing or when getting client acting <a shape="rect" class="
 external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-assertions-10#section-6.2" rel="nofollow">on behalf of itself</a> for example.</p><p>Instead of using SelfSignInfo utility one can create an empty CXF Message and set required properties on it and passing it to SAMLUtils - see the example on how to use SAML Bearer assertions for the authentication below.</p><p>When doing step 2, the main effort is to do with getting a SAML assertion populated - use a SAML callback handler like <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/SamlCallbackHandler.java">this one</a>, it is actually quite easy to build the assertion.</p><h3 id="JAXRSOAuth2Assertions-AccessTokenService">Access Token Service</h3><p>Here is how one may configure Access Token Service:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>The code above prepares an info for a new SAML assertion be self-signed, loading a Crypto instance with crypto <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/alice.properties">properties</a>, and uses SAMLUtils to create and sign the assertion (using Crypto, plus user alias and password). Saml2BearerGrant will get the assertion Base64Url-encoded - unless the assertion has already been encoded with CXF Base64UrlUtility or came encoded from IP - in this case Saml2BearerGrant constructor accepting an 'encoded' property will have to be used, with the value set to "true".</p><p>This is nearly as simple as using other token grants, the step 2 will often me omitted in more involved cases as it will be the job of Identity Providers to issue OAuth2 SAML2 Bearer assertions. Step 2 needs to be done when testing or when getting client acting <a shape="rect" class="
 external-link" href="http://tools.ietf.org/html/rfc7521#section-6.2" rel="nofollow">on behalf of itself</a> for example.</p><p>Instead of using SelfSignInfo utility one can create an empty CXF Message and set required properties on it and passing it to SAMLUtils - see the example on how to use SAML Bearer assertions for the authentication below.</p><p>When doing step 2, the main effort is to do with getting a SAML assertion populated - use a SAML callback handler like <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/SamlCallbackHandler.java">this one</a>, it is actually quite easy to build the assertion.</p><h3 id="JAXRSOAuth2Assertions-AccessTokenService">Access Token Service</h3><p>Here is how one may configure Access Token Service:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;bean id="dataProvider" class="org.apache.cxf.systest.jaxrs.security.oauth2.OAuthDataProviderImpl"/&gt;
 &lt;bean id="samlGrantHandler" class="org.apache.cxf.rs.security.oauth2.grants.saml.Saml2BearerGrantHandler"&gt;
   &lt;property name="dataProvider" ref="dataProvider"/&gt;
@@ -309,7 +311,7 @@ ClientAccessToken at = OAuthClientUtils.
         
 &lt;/jaxrs:server&gt;
 </pre>
-</div></div><h2 id="JAXRSOAuth2Assertions-ClientActingonBehalfofItself">Client Acting on Behalf of Itself</h2><p>In the <a shape="rect" class="external-link" href="http://tools.ietf.org/html/draft-ietf-oauth-assertions-10#section-6.2" rel="nofollow">Client Acting on Behalf of Itself</a> use either org.apache.cxf.rs.security.oauth2.grants.saml.Saml2BearerClientCredentialsGrant :</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h2 id="JAXRSOAuth2Assertions-ClientActingonBehalfofItself">Client Acting on Behalf of Itself</h2><p>In the <a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7521#section-6.2" rel="nofollow">Client Acting on Behalf of Itself</a> use either org.apache.cxf.rs.security.oauth2.grants.saml.Saml2BearerClientCredentialsGrant :</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.rs.security.common.CryptoLoader;
 import org.apache.cxf.rs.security.oauth2.client.OAuthClientUtils;
@@ -361,7 +363,46 @@ AccessTokenGrant accessTokenGrant = new
        
 ClientAccessToken at = OAuthClientUtils.getAccessToken(wc, accessTokenGrant);
 </pre>
-</div></div><p>&#160;</p><h1 id="JAXRSOAuth2Assertions-JWTBearer">JWT Bearer</h1><p>&#160;</p><h2 id="JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</h2><p>As noted in the introduction, JWT Bearer tokens may also act as client authentication credentials, when requesting an access token, irrespectively of the actual grant type. For example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>&#160;</p><h1 id="JAXRSOAuth2Assertions-JWTBearer">JWT Bearer</h1><h2 id="JAXRSOAuth2Assertions-AccessTokenGrant.1">Access Token Grant</h2><p><a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7523#section-2.1" rel="nofollow">This section</a> explains how JWT Bearer tokens can be used as token grants. The value of grant_type parameter is "urn:ietf:params:oauth:grant- type:jwt-bearer".</p><p>It is really just another grant type, but whose actual value is a JWT Token. The specification provides an <a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc7523#section-4" rel="nofollow">example</a> of how such an assertion may look like.</p><p>Here is how a request may look like:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">POST /token HTTP/1.1
+Content-Type: application/x-www-form-urlencoded
+
+grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&amp;
+assertion=X.Y.Z
+</pre>
+</div></div><h3 id="JAXRSOAuth2Assertions-Clientcode.1">Client code</h3><p>The following example shows how to use JWT Bearer token as a grant with CXF OAuth2 client code: TODO</p><h3 id="JAXRSOAuth2Assertions-AccessTokenService.2">Access Token Service</h3><p>Here is how one may configure the Access Token Service:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;bean id="dataProvider" class="org.apache.cxf.systest.jaxrs.security.oauth2.OAuthDataProviderImpl"/&gt;
+&lt;bean id="jwtGrantHandler" class="org.apache.cxf.rs.security.oauth2.grants.jwt.JwtBearerGrantHandler"&gt;
+  &lt;property name="dataProvider" ref="dataProvider"/&gt;
+&lt;/bean&gt;
+&lt;bean id="oauthJson" class="org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider"/&gt;
+
+&lt;bean id="serviceBean" class="org.apache.cxf.rs.security.oauth2.services.AccessTokenService"&gt;
+  &lt;property name="dataProvider" ref="dataProvider"/&gt;
+  &lt;property name="grantHandlers"&gt;
+     &lt;list&gt;
+       &lt;ref bean="jwtGrantHandler"/&gt;
+     &lt;/list&gt;
+  &lt;/property&gt;
+&lt;/bean&gt;
+
+&lt;jaxrs:server address="https://localhost:${testutil.ports.jaxrs-oauth2}/oauth2"&gt;
+   &lt;jaxrs:serviceBeans&gt;
+      &lt;ref bean="serviceBean"/&gt;
+   &lt;/jaxrs:serviceBeans&gt;
+   &lt;jaxrs:providers&gt;
+      &lt;ref bean="oauthJson"/&gt;
+   &lt;/jaxrs:providers&gt;
+   &lt;jaxrs:properties&gt;
+      &lt;entry key="rs.security.keystore.type" value="jks" /&gt;
+      &lt;entry key="rs.security.keystore.alias" value="myclientkey"/&gt;
+      &lt;entry key="rs.security.keystore.password" value="cspass"/&gt;
+      &lt;entry key="rs.security.keystore.file" value="clientstore.jks" /&gt;
+      &lt;entry key="rs.security.signature.algorithm" value="RS256" /&gt;
+   &lt;/jaxrs:properties&gt;
+&lt;/jaxrs:server&gt;
+</pre>
+</div></div><h2 id="JAXRSOAuth2Assertions-AuthenticationToken.1">Authentication Token</h2><p>As noted in the introduction, JWT Bearer tokens may also act as client authentication credentials, when requesting an access token, irrespectively of the actual grant type. For example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">POST /token HTTP/1.1
 Content-Type: application/x-www-form-urlencoded
 
@@ -370,7 +411,7 @@ grant_type=authorization_code
 &amp;client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
 &amp;client_assertion=X.Y.Z
 </pre>
-</div></div><p>Note "client_assertion_type" with a value "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" indicates that the type of assertion used as an authentication token is "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", while the "client_assertion" parameter carries the actual value of the token.</p><h3 id="JAXRSOAuth2Assertions-ClientCode.1">Client Code</h3><p>The following example shows how to use JWT Bearer tokens as an authentication token: TODO</p><p>&#160;</p><h3 id="JAXRSOAuth2Assertions-AccessTokenService.2">Access Token Service</h3><p>Here is how one may configure Access Token Service:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Note "client_assertion_type" with a value "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" indicates that the type of assertion used as an authentication token is "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", while the "client_assertion" parameter carries the actual value of the token.</p><h3 id="JAXRSOAuth2Assertions-ClientCode.1">Client Code</h3><p>The following example shows how to use JWT Bearer tokens as an authentication token: TODO</p><p>&#160;</p><h3 id="JAXRSOAuth2Assertions-AccessTokenService.3">Access Token Service</h3><p>Here is how one may configure Access Token Service:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;bean id="dataProvider" class="org.apache.cxf.systest.jaxrs.security.oauth2.OAuthDataProviderImpl"/&gt;
 &lt;bean id="oauthJson" class="org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider"/&gt;
 &lt;bean id="jwtAuthHandler" class="org.apache.cxf.rs.security.oauth2.grants.jwt.JwtBearerAuthHandler"/&gt;