Skip to content

Commit

Permalink
Merge pull request #3988 from zowe/reboot/fix/x509-zos-config
Browse files Browse the repository at this point in the history
Fix x.509 configuration requirements for RACF
  • Loading branch information
janan07 authored Nov 11, 2024
2 parents 8c0b872 + c05f819 commit 8110cb6
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 47 deletions.
100 changes: 69 additions & 31 deletions docs/user-guide/authenticating-with-client-certificates.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
:::info Required roles: system administrator, security administrator
:::

Authentication for integration with API Mediation Layer (API ML) can also be performed by the client when the service endpoint is called through
Authentication for integration with API Mediation Layer (API ML) can also be performed by the client when the service endpoint is called through
the API ML Gateway with client certificates. This method of authentication requires client certification to be enabled and configured. For details about this configuration, see [Enabling single sign on for clients via client certificate configuration](./api-mediation/configuration-client-certificates.md).

:::note Notes:

* When calling the login endpoint with basic authentication credentials, as well as with client certificate, the basic
authentication credentials take precedence and the client certificate is ignored.
authentication credentials take precedence and the client certificate is ignored.

* If you are calling a specific endpoint on one of the onboarded services, API Mediation Layer ignores Basic authentication. In this case, the Basic authentication is not part of the authenticated request.
:::

## How the Gateway resolves authentication
## How the Gateway resolves authentication

When sending a request to a service with a client certificate, the Gateway performs the following process to resolve authentication:

Expand All @@ -30,36 +31,54 @@ When sending a request to the login endpoint with a client certificate, the Gate
4. The Gateway then performs the login of the mapped user and returns a valid JWT token.

:::note Notes:

* As of Zowe release 3.0.0, the Internal API ML Mapper is the default API that provides this mapping between the public part of the client certificate and SAF user ID. Alternatively, you can use Z Secure Services (ZSS) to provide this API for API ML, with the noted exception when using ACF2, although we recommend using the internal API ML mapper.
* For information about ZSS, see the section Zowe runtime in the [Zowe server-side installation overview](./install-zos.md).
:::

The following diagram shows how routing works with ZSS, in the case where the ZSS API is used for the identity mapping.
The following diagram shows how routing works with ZSS, in the case where the ZSS API is used for the identity mapping.

![Zowe client certificate authentication diagram](../images/api-mediation/zowe-client-cert-auth.png)

:::tip
For more information, see the Medium blog post [Zowe client certificate authentication](https://medium.com/zowe/zowe-client-certificate-authentication-5f1c7d4d579).
:::

## Configure your z/OS system to support client certificate authentication for a specific user
## Configure your z/OS system to support client certificate authentication for specific users

Register the client certificate with the user IDs in your ESM.

The following commands show options for both the internal API ML mapper and ZSS.

:::note

Register the client certificate with the user ID in your ESM. The following commands apply to both the internal API ML mapper and ZSS.
If using the internal API ML mapper (default from Zowe v3) and the MAP / CERTMAP option with distinguished name filters, use the `CHCKCERT` or equivalent command on the certificate to use the same order and format of the certificate's distinguished name as displayed.
:::

**RACF**
**RACF**
<details>
<summary>Click here for an example command in RACF. </summary>
<summary>Click here for an example command in RACF. </summary>

```
RACDCERT ADD(<dataset>) ID(<userid>) WITHLABEL('<label>') TRUST
SETROPTS RACLIST(DIGTCERT, DIGTRING) REFRESH
Activate the `DIGTNMAP` class:

```racf
SETROPTS CLASSACT(DIGTNMAP) RACLIST(DIGTNMAP)
```
Alternatively, if you are using the internal API ML mapper, use the following command:

```
Create the mapping for the user and a distinguished name filter:

```racf
RACDCERT ID(<userid>) MAP
SDNFILTER('<subject's-distinguished-name-filter>')
WITHLABEL('<label>')
SETROPTS RACLIST(DIGTMAP) REFRESH
```

Alternatively, if you disabled the internal API ML mapper, use the following command to add the certificate to an ACID:

```racf
RACDCERT ADD(<dataset>) ID(<userid>) WITHLABEL('<label>') TRUST
SETROPTS RACLIST(DIGTCERT, DIGTRING) REFRESH
```

</details>
Expand All @@ -69,59 +88,78 @@ Alternatively, if you are using the internal API ML mapper, use the following co
<details>
<summary>Click here for an example command in ACF2. </summary>

`INSERT <userid>.<certname> DSNAME('<dataset>') LABEL(<label>) TRUST`
Create the mapping for the user and a distinguished name filter:

Alternatively, if you are using the internal API ML mapper, use the following command:

```
```acf2
CERTMAP.<recid>
SDNFILTR(<subject's-distinguished-name-filter>)
LABEL(<label>)
USERID(<userid>)
TRUST
```

</details>

Alternatively, if you disabled the internal API ML mapper, use the following command to add the certificate to an ACID

**Top Secret**
```acf2
INSERT <userid>.<certname> DSNAME('<dataset>') LABEL(<label>) TRUST
```

<details>
<summary>Click here for an example command in Top Secret. </summary>
</details>

`TSS ADDTO(<userid>) DIGICERT(<certname>) LABLCERT('<label>') DCDSN('<dataset>') TRUST`
**Top Secret**

Alternatively, if you are using the internal API ML mapper, use the following command:
<details>
<summary>Click here for an example command in Top Secret. </summary>

```
Create the mapping for the user and a distinguished name filter:

```tss
TSS ADDT0(<userid>) CERTMAP(<recid>)
SDNFILTR('<subject's-distinguished-name-filter>')
USERID(<userid>)
TRUST
```
</details>

Alternatively, if you disabled the internal API ML mapper, use the following command to add the certificate to an ACID:

```tss
TSS ADDTO(<userid>) DIGICERT(<certname>) LABLCERT('<label>') DCDSN('<dataset>') TRUST
```

</details>

Additional details are likely described in your security system documentation.

:::note Notes

* The alternative ESM map commands allow mapping a certificate to a user without adding the X.509 certificate to the ESM database. While this approach is more convenient, it could be considered less secure than adding the certificate to the ACID, which offers better control and protection.
* Ensure that you have the Issuer certificate imported in the truststore or in the SAF keyring. Alternatively, you can generate these certificates in SAF.
* Ensure that the client certificate has the following `Extended Key Usage` metadata:
`OID: 1.3.6.1.5.5.7.3.2`
This metadata can be used for TLS client authentication.
:::


## Validate the client certificate functionality

To validate that the client certificate functionality works properly, call the login endpoint with the certificate that was set up using the steps in [Configure your z/OS system to support client certificate authentication for a specific user](#configure-your-zos-system-to-support-client-certificate-authentication-for-a-specific-user) described previously in this article.
To validate that the client certificate functionality works properly, call the login endpoint with the certificate that was set up using the steps in [Configure your z/OS system to support client certificate authentication for a specific user](#configure-your-zos-system-to-support-client-certificate-authentication-for-specific-users) described previously in this article.

Validate using _CURL_, a command line utility that runs on Linux based systems:

**Example:**

```bash
curl -X POST \
--cert /path/to/cert.pem \
--key /path/to/key.pem \
https://api-mediation-layer:7554/gateway/api/v1/auth/login -v
```
curl --cert /path/to/cert.pem --key /path/to/key.pem https://api-mediation-layer:7554/gateway/api/v1/login
```
Your Zowe instance is configured to accept x.509 client certificates authentication.

Where:

* `cert`: Specifies the certificate location
* `key`: Path to the private key
* `7554`: Replace with the configured API Gateway port in the intance

x.509 Client Certificate authentication is correctly configured if the result of the request is HTTP 200 with an `apimlAuthenticationToken` cookie generated.

Your Zowe instance is configured to accept x.509 client certificates authentication.
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ Authentication for integration with API Mediation Layer (API ML) can also be per
the API ML Gateway with client certificates. Client certification must be enabled and configured. For details about this configuration, see [Enabling single sign on for clients via client certificate configuration](./api-mediation/configuration-client-certificates.md).

:::note Notes:

* When calling the login endpoint with basic authentication credentials, as well as with client certificate, the basic
authentication credentials take precedence and the client certificate is ignored.
authentication credentials take precedence and the client certificate is ignored.

* If you are calling a specific endpoint on one of the onboarded services, API Mediation Layer ignores Basic authentication. In this case, the Basic authentication is not part of the authenticated request.
:::

## How the Gateway resolves authentication
## How the Gateway resolves authentication

When sending a request to a service with a client certificate, the Gateway performs the following process to resolve authentication:

1. The client calls the service endpoint through the API ML Gateway with the client certificate.
2. The client certificate is verified as a valid TLS client certificate against the trusted certificate authorities (CAs) of the Gateway.
3. The public key of the provided client certificate is verified against SAF. SAF subsequently returns a user ID that owns this certificate. As of Zowe version 2.14, the API for API ML can be provided by the internal API ML mapper if the mapper is enabled. Alternatively, you can use Z Secure Services (ZSS) to provide this API for API ML, although we recommend using the internal API ML mapper.
4. The Gateway then performs the login of the mapped user and provides valid authentication to the downstream service.
4. The Gateway then performs the login of the mapped user and provides valid authentication to the downstream service.

:::note Notes:

* Currently, ZSS is the default API that provides this mapping between the public part of the client certificate and SAF user ID. However, the recommended method is to use the internal API ML mapper. For information about the enabling the internal API ML mapper, see [Configure Internal API ML Mapper](./api-mediation/configuration-client-certificates.md#configure-internal-api-ml-mapper) in the article _Enabling single sign on for clients via client certificate configuration_.
* For information about ZSS, see the section Zowe runtime in the [Zowe server-side installation overview](./install-zos.md).
:::
Expand All @@ -38,7 +40,7 @@ When sending a request to the login endpoint with a client certificate, the Gate
ZSS is currently the default API that provides this mapping between the public part of the client certificate and SAF user ID. Using the internal API ML mapper is, however, the recommended method.
:::

The following diagram shows how routing works with ZSS.
The following diagram shows how routing works with ZSS.

![Zowe client certificate authentication diagram](../images/api-mediation/zowe-client-cert-auth.png)

Expand All @@ -48,38 +50,55 @@ For more information, see the Medium blog post [Zowe client certificate authenti

## Configure your z/OS system to support client certificate authentication for a specific user

Register the client certificate with the user ID in your ESM. The following commands apply to both the internal API ML mapper and ZSS.
Register the client certificate with the user ID in your ESM. The following commands show options for both the internal API ML mapper and ZSS.

:::note

If using the internal API ML mapper and the MAP / CERTMAP option with distinguished name filters, use the `CHCKCERT` or equivalent command on the certificate to use the same order and format of the certificate's distinguished name as displayed.
:::

**RACF**

<details>
<summary>Click here for command details for RACF.</summary>

```
``` racf
RACDCERT ADD(<dataset>) ID(<userid>) WITHLABEL('<label>') TRUST
SETROPTS RACLIST(DIGTCERT, DIGTRING) REFRESH
```
Alternatively, if you are using the internal API ML mapper, you can use the following command:

Alternatively, if you are using the internal API ML mapper, you can use the following commands:

Activate the `DIGTNMAP` class:

```racf
SETROPTS CLASSACT(DIGTNMAP) RACLIST(DIGTNMAP)
```

Add mapping to the user:

```racf
RACDCERT ID(<userid>) MAP
SDNFILTER('<subject's-distinguished-name-filter>')
WITHLABEL('<label>')
```

**Note:** The `RACDCERT MAP` command allows mapping a certificate to a user without adding the X.509 certificate to the ESM database. While this approach is more convenient, it could be considered less secure than adding the certificate to the ACID, which offers better control and protection.

</details>

**ACF2**
**ACF2**

<details>
<summary>Click here for command details for ACF2.</summary>

`INSERT <userid>.<certname> DSNAME('<dataset>') LABEL(<label>) TRUST`
```acf2
INSERT <userid>.<certname> DSNAME('<dataset>') LABEL(<label>) TRUST
```

Alternatively, if you are using the internal API ML mapper, you can use the following command:

```
```acf2
CERTMAP.<recid>
SDNFILTR(<subject's-distinguished-name-filter>)
LABEL(<label>)
Expand All @@ -94,11 +113,13 @@ Register the client certificate with the user ID in your ESM. The following comm
<details>
<summary>Click here for command details for Top Secret.</summary>

`TSS ADDTO(<userid>) DIGICERT(<certname>) LABLCERT('<label>') DCDSN('<dataset>') TRUST`
```
TSS ADDTO(<userid>) DIGICERT(<certname>) LABLCERT('<label>') DCDSN('<dataset>') TRUST
```

Alternatively, in case you are using the internal API ML mapper, you can use the following command:

```
```tss
TSS ADDT0(<userid>) CERTMAP(<recid>)
SDNFILTR('<subject's-distinguished-name-filter>')
USERID(<userid>)
Expand All @@ -110,6 +131,7 @@ Alternatively, in case you are using the internal API ML mapper, you can use the
Additional details are likely described in your security system documentation.

:::note Notes

* ZSS is currently the default API that provides this mapping between the public part of the client certificate and SAF user ID. Using the internal API ML mapper is, however, the recommended method.
* The alternative ESM map commands allow mapping a certificate to a user without adding the X.509 certificate to the ESM database. While this approach is more convenient, it could be considered less secure than adding the certificate to the ACID, which offers better control and protection.
* Ensure that you have the Issuer certificate imported in the truststore or in the SAF keyring. Alternatively, you can generate these certificates in SAF.
Expand All @@ -118,16 +140,27 @@ Alternatively, in case you are using the internal API ML mapper, you can use the
This metadata can be used for TLS client authentication.
:::


## Validate the client certificate functionality

To validate that the client certificate functionality works properly, call the login endpoint with the certificate that was set up using the steps in [Configure your z/OS system to support client certificate authentication for a specific user](#configure-your-zos-system-to-support-client-certificate-authentication-for-a-specific-user) described previously in this article.

Validate using _CURL_, a command line utility that runs on Linux based systems:

**Example:**

```bash
curl -X POST \
--cert /path/to/cert.pem \
--key /path/to/key.pem \
https://api-mediation-layer:7554/gateway/api/v1/auth/login -v
```
curl --cert /path/to/cert.pem --key /path/to/key.pem https://api-mediation-layer:7554/gateway/api/v1/login
```
Your Zowe instance is configured to accept x.509 client certificates authentication.

Where:

* `cert`: Specifies the certificate location
* `key`: Path to the private key
* `7554`: Replace with the configured API Gateway port in the intance

x.509 Client Certificate authentication is correctly configured if the result of the request is HTTP 200 with an `apimlAuthenticationToken` cookie generated.

Your Zowe instance is configured to accept x.509 client certificates authentication.

0 comments on commit 8110cb6

Please sign in to comment.