Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 358F7200CA8 for ; Thu, 15 Jun 2017 14:47:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 33FE8160BDF; Thu, 15 Jun 2017 12:47:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 03733160BC4 for ; Thu, 15 Jun 2017 14:47:49 +0200 (CEST) Received: (qmail 20457 invoked by uid 500); 15 Jun 2017 12:47:49 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 20446 invoked by uid 99); 15 Jun 2017 12:47:49 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Jun 2017 12:47:49 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id DA5653A002A for ; Thu, 15 Jun 2017 12:47:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1014072 - in /websites/production/cxf/content: cache/docs.pageCache docs/jax-rs-jose.html Date: Thu, 15 Jun 2017 12:47:45 -0000 To: commits@cxf.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170615124747.DA5653A002A@svn01-us-west.apache.org> archived-at: Thu, 15 Jun 2017 12:47:51 -0000 Author: buildbot Date: Thu Jun 15 12:47:45 2017 New Revision: 1014072 Log: Production update by buildbot for cxf Modified: websites/production/cxf/content/cache/docs.pageCache websites/production/cxf/content/docs/jax-rs-jose.html Modified: websites/production/cxf/content/cache/docs.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/cxf/content/docs/jax-rs-jose.html ============================================================================== --- websites/production/cxf/content/docs/jax-rs-jose.html (original) +++ websites/production/cxf/content/docs/jax-rs-jose.html Thu Jun 15 12:47:45 2017 @@ -119,11 +119,11 @@ Apache CXF -- JAX-RS JOSE

 

 

Note the Base64Url encoded protected headers go first, followed by the 'recipients' array, with each element containing the encrypted content encryption key which can be decrypted by the recipient private key, with the array of recipients followed by the IV, ciphertext and authentication tag Base64Url sequences.

Linking JWT authentications to JWS or JWE content

CXF introduced a "JWT" HTTP authentication scheme, with a Base64Url encoded JWT token representing a user authentication against an IDP capable of issuing JWT assertions (or simply JWT tokens). JWT assertion is like SAML assertion except that it is in a JSON format. If you'd like to cryptographically bind this JWT token to a data secured by JWS and/or JWE processors then simply add JwtAuthenticationClientFilteron the client side and JwtAuthenticationFilter on the server side. These filters link the authentication token with a randomly generated secure value which is added to both the token and the body JWS/JWE protected headers.

This approach is more effective compared to the ones where the body hash is calculated before it is submitted to a signature creation function, with the signature added as HTTP header.

Optional protection of HTTP headers

Starting from CXF 3.1.12 it is possible to use JWS, JWS JSON, JWE and JWE JSON filters to protect the selected set of HTTP headers. The JOSE payloads produced b y these filters guarantee that the JOSE headers are integrity protected. Given this, if one enables a 'protectHttpHeaders' boolean property on the request filters, then, by default, HTTP Content-Type and Accept header values will be registered as JOSE header properties prefixed with "http.", example, "http.Accept":"text/plain". The list of the headers to be protected can be customized using a 'protectedHttpHeaders' set property.

These properties will be compared against the current HTTP headers on the receiving end.

This approach does not prevent the streaming of the outgoing data (which will also be protected by the filters) and offers a way to secure the HTTP headers which are really important for the correct processing of the incoming payloads

Configuration

CXF JOSE configuration provides for loading JWS and JWE keys and supporting various processing options. Configuration properties can be shared between JWS and JWE process ors or in/out only JWS and or JWE properties can be set.

Typically a secure JAX-RS endpoint or client is initialized with JWS and or JWE properties.

For example, this endpoint is configured with a single JWS properties file which will apply to both input (signature verification) and output (signature creation) JWS operations. This endpoint depends on two JWS properties files, one - for input JWS, another one - for output JWS. Similarly, this endpoint uses a single JWE properties file for encrypting/decrypting the data, while this endpoint uses two JWE properties files. This endpoint support both JWS and JSON with in/out specific properties. If either JWS or JWE private key needs to be loaded from the password-protected storage (JKS, encryped JWK)  then a password provider needs be registered as well, it can be shared between JWS or JWS or be in/out specific for either JWS or JWE.

These configuration propertie are of major help when JAX-RS JOSE filters process the in/out payload without the application service code being aware of it. While filters can be injected with JWS or JWE providers directly, one would usually set the relevant properties as part of the endpoint or client set-up and expect the filters load the required JWS or JWE providers as needed. 

If you need to do JWS or JWE processing directly in your service or interceptor code then having the properties may al so be helpful, for example, the following code works because it is indirectly supported by the properties indicating which signature or encryption algorithm is used, where to get the key if needed, etc:

Loading JWS and JWE Providers
+

Note the Base64Url encoded protected headers go first, followed by the 'recipients' array, with each element containing the encrypted content encryption key which can be decrypted by the recipient private key, with the array of recipients followed by the IV, ciphertext and authentication tag Base64Url sequences.

Linking JWT authentications to JWS or JWE content

CXF introduced a "JWT" HTTP authentication scheme, with a Base64Url encoded JWT token representing a user authentication against an IDP capable of issuing JWT assertions (or simply JWT tokens). JWT assertion is like SAML assertion except that it is in a JSON format. If you'd like to cryptographically bind this JWT token to a data secured by JWS and/or JWE processors then simply add JwtAuthenticationClientFilteron the client side and JwtAuthenticationFilter on the server side. These filters link the authentication token with a randomly generated secure value which is added to both the token and the body JWS/JWE protected headers.

This approach is more effective compared to the ones where the body hash is calculated before it is submitted to a signature creation function, with the signature added as HTTP header.

Optional protection of HTTP headers

Starting from CXF 3.1.12 it is possible to use JWS, JWS JSON, JWE and JWE JSON filters to protect the selected set of HTTP headers. The JOSE payloads produced b y these filters guarantee that the JOSE headers are integrity protected. Given this, if one enables a 'protectHttpHeaders' boolean property on the request filters, then, by default, HTTP Content-Type and Accept header values will be registered as JOSE header properties prefixed with "http.", example, "http.Accept":"text/plain". The list of the headers to be protected can be customized using a 'protectedHttpHeaders' set property.

These properties will be compared against the current HTTP headers on the receiving end.

This approach does not prevent the streaming of the outgoing data (which will also be protected by the filters) and offers a way to secure the HTTP headers which are really important for the correct processing of the incoming payloads

JOSE in JAX-RS application code

In some cases you may need to create or process the JOSE data directly in the service or client application code. For example, one of the properties in the request or response payload needs to be JWS signed/verified and/or JWE encrypted/decrypted. The following 2 options can be tried.

Option 1:  Process JOSE directly

This option is about using the CXF JOSE library to sign, encrypt, or/and decrypt and verify the data as documented above. This option should be preferred if one needs to keep a closer control, for example, set the custom JWS or JWE headers, etc.

Option 2:  Use JOSE library helpers and Endpoint Configuration

This option makes it straighforward to do JOSE in the application code. One has to extend or delegate to a specific JOSE helper instance and configure the endpoint with the locatiion of the key store.

Produce JOSE data

Step1. Use JoseProducer or JoseJwtProducer

Step2. Set the key store location

Consume JOSE data

Step1. Use JoseConsumer or JoseJwtConsumer

Step2. Set the key store location

Produce and Consume JOSE data

Step1. Use JoseProducerConsumer or JoseJwtProducerConsumer

Step2. Set the key store location

Configuration

CXF JOSE configuration provides for loading JWS and JWE keys and supporting various processing options. Configuration properties can be shared between JWS and JWE processors or in/out only JWS and or JWE properties can be set.

Typic ally a secure JAX-RS endpoint or client is initialized with JWS and or JWE properties.

For example, this endpoint is configured with a single JWS properties file which will apply to both input (signature verification) and output (signature creation) JWS operations. This endpoint depends on two JWS properties files, one - for input JWS, another one - for output JWS. Similarly, this endpoint uses a single JWE properties file for encrypting/decrypting the data, while this endpoint uses two JWE properties files. This endpoint support both JWS and JSON with in/out specific properties. If either JWS or JWE private key needs to be loaded from the password-protected storage (JKS, encryped JWK)  then a password provider needs be registered as well, it can be shared between JWS or JWS or be in/out specific for either JWS or JWE.

These configuration propertie are of major help when JAX-RS JOSE filters process the in/out payload without the application service code being aware of it. While filters can be injected with JWS or JWE providers directly, one would usually set the relevant properties as part of the endpoint or client set-up and expect the filters load the required JWS or JWE providers as needed. 

If you need to do JWS or JWE processing directly in your service or interceptor code then having the properties may also be helpful, for example, the following code works because it is i ndirectly supported by the properties indicating which signature or encryption algorithm is used, where to get the key if needed, etc:

Loading JWS and JWE Providers
JwsSignatureProvider jwsOut = JwsUtils.loadSignatureProvider(true);
 JwsSignatureVerifier jwsIn = JwsUtils.loadSignatureVerifier(true);