Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONYX-14324 - authn-jwt - enhance public key delivery mechanisms #2437

Merged
merged 2 commits into from
Dec 27, 2021

Conversation

sashaCher
Copy link
Contributor

@sashaCher sashaCher commented Dec 9, 2021

What this does PR do?

Introduces design for two new configuration variables of JWT authenticator.

Connected Issue/Story

ONYX-14324

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: insert issue ID
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@sashaCher sashaCher requested a review from a team December 9, 2021 12:34
@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch 5 times, most recently from a260705 to 2ea3511 Compare December 12, 2021 20:07
@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from 9b4be9c to 374288c Compare December 14, 2021 12:18
[//]: # "2. Design documents should not be updated after implementation"
[//]: # "3. Design decisions should be made before writing this document, and as such this document should not include options / choices"


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple consecutive blank lines

@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from bfe6313 to 1437409 Compare December 15, 2021 11:46

```bash
conjur variable set -i conjur/authn-jwt/myUnreachableVendor/public-keys \
"{ \"type\":\"jwks\", \"value\": $(curl https://www.googleapis.com/oauth2/v3/certs) }"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from 23c302c to a82e16d Compare December 21, 2021 11:45
@sashaCher sashaCher marked this pull request as ready for review December 21, 2021 11:47
@sashaCher sashaCher requested a review from a team as a code owner December 21, 2021 11:47
@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from a82e16d to e7cc563 Compare December 21, 2021 11:49

| **Error message** | **Description** |
|-------------------|-----------------|
| Signing key configuration is invalid: JSON parsing error from JSON gem | When the variable value is not a valid JSON |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

| **Error message** | **Description** |
|-------------------|-----------------|
| Signing key configuration is invalid: JSON parsing error from JSON gem | When the variable value is not a valid JSON |
| Signing key configuration is invalid: `public-keys` `type` field value is missing or empty | When type field absent or has empty value |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

|-------------------|-----------------|
| Signing key configuration is invalid: JSON parsing error from JSON gem | When the variable value is not a valid JSON |
| Signing key configuration is invalid: `public-keys` `type` field value is missing or empty | When type field absent or has empty value |
| Signing key configuration is invalid: `public-keys` `type` field value {} is wrong | When type field value is no `jwks` |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

| Signing key configuration is invalid: JSON parsing error from JSON gem | When the variable value is not a valid JSON |
| Signing key configuration is invalid: `public-keys` `type` field value is missing or empty | When type field absent or has empty value |
| Signing key configuration is invalid: `public-keys` `type` field value {} is wrong | When type field value is no `jwks` |
| Signing key configuration is invalid: `public-keys` `value` field is missing or empty | When value field absent or has empty value |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

| S1 | 3 SP |
| S2 | 2 SP |
| S3 | 3 SP (without integration tests) |
| S4 | 2 SP (considering spike code [cyberark/conjur#2447](https://github.com/cyberark/conjur/pull/2447)) |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length


* `public-keys` - a variable contains static JWKS value for the case where Conjur
is unable to reach server hosts jwks/provider-uri.
<details>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

supported. More types can be supported in future.
* `value` - the value of JWKS as is it's returned from unreachable jwks/provider-uri
endpoint.
<details><summary>JSON example</summary>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

supported. More types can be supported in future.
* `value` - the value of JWKS as is it's returned from unreachable jwks/provider-uri
endpoint.
<details><summary>JSON example</summary>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from 2eaa2e5 to 5cfcd06 Compare December 22, 2021 08:30
* `ca-cert` - a variable contains certificates bundle with additional CA certificates
conjur will trust when it
approaches jwks/provider uri.
<details>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


The `ca-cert` variable format is a certificate bundle contains one or more certificates
in pem ([rfc7468](https://datatracker.ietf.org/doc/html/rfc7468)) format.
<details><summary>Bundle example</summary>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


The `ca-cert` variable format is a certificate bundle contains one or more certificates
in pem ([rfc7468](https://datatracker.ietf.org/doc/html/rfc7468)) format.
<details><summary>Bundle example</summary>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

requirements.

1. Create abstraction layer for relevant Conjur variables from authenticator's BL
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

requirements.

1. Create abstraction layer for relevant Conjur variables from authenticator's BL
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

* `signing_key`: String - returns `public-keys` variable value
* `ca_cert`: `OpenSSL::X509::Store`<br>
Store creation example
```ruby
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenced code blocks should be surrounded by blank lines

</div></details>

1. Add new properties to `SigningKeySettings` class
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

</div></details>

1. Add new properties to `SigningKeySettings` class
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

Add new properties to the `SigningKeySettings` class:

* `signing_key`: String - returns `public-keys` variable value
* `ca_cert`: `OpenSSL::X509::Store`<br>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

Store creation example
```ruby
ca_cert = OpenSSL::X509::Store.new
::Conjur::CertUtils.add_chained_cert(ca_cert, <VARIABLE_VALUE>)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


1. Use additional CA certificates during keys fetching in both `jwks-uri` and `provider-uri`
use cases
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


1. Use additional CA certificates during keys fetching in both `jwks-uri` and `provider-uri`
use cases
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


1. Refactor cache layer related to `FetchProviderUriSigningKey` and `FetchJwksUriSigningKey`
classes
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


1. Refactor cache layer related to `FetchProviderUriSigningKey` and `FetchJwksUriSigningKey`
classes
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


1. Create new `FetchStaticSigningKey` class parses the `public-keys` variable value
and returns a valid JWKS structure
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

public-keys configuration, and non-functional - decoupling variables from main BL
requirements.

1. <a name="s1"></a>Create abstraction layer for relevant Conjur variables from
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML


</div></details>

1. <a name="s2"></a>Add new properties to `SigningKeySettings` class
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

Fallback scenario: to support `ca-cert` variable only for `jwks-uri` variable.
</div></details>

1. <a name="s4"></a>Refactor cache layer related to `FetchProviderUriSigningKey`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

![image](fetch-more-keys-stage-4.png)
</div></details>

1. <a name="s5"></a>Create new `FetchStaticSigningKey` class parses the `public-keys`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from 5d77a25 to 959b682 Compare December 26, 2021 13:35

| **Error message** | **Description** |
|-------------------|-----------------|
| Signing key configuration is invalid: only one of `jwks-uri`, `provider-uri`, `public-keys` variables can be define simultaneously | When more than one variable is defined |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

| **Error message** | **Description** |
|-------------------|-----------------|
| Signing key configuration is invalid: only one of `jwks-uri`, `provider-uri`, `public-keys` variables can be define simultaneously | When more than one variable is defined |
| Signing key configuration is invalid: `ca-cert` variable can be defined only with `jwks-uri` variables | When `ca-cert` variable defined with `provider-uri` or `public-keys` variables |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

|-------------------|-----------------|
| Signing key configuration is invalid: only one of `jwks-uri`, `provider-uri`, `public-keys` variables can be define simultaneously | When more than one variable is defined |
| Signing key configuration is invalid: `ca-cert` variable can be defined only with `jwks-uri` variables | When `ca-cert` variable defined with `provider-uri` or `public-keys` variables |
| Signing key configuration is invalid: missing `issuer` variable | When `public-keys` variable is defined but `issuer` is not |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

| Signing key configuration is invalid: only one of `jwks-uri`, `provider-uri`, `public-keys` variables can be define simultaneously | When more than one variable is defined |
| Signing key configuration is invalid: `ca-cert` variable can be defined only with `jwks-uri` variables | When `ca-cert` variable defined with `provider-uri` or `public-keys` variables |
| Signing key configuration is invalid: missing `issuer` variable | When `public-keys` variable is defined but `issuer` is not |
| Signing key configuration is invalid: {variable-name} variable is defined but empty | When variables permutation is valid but one of it is empty |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length


</div></details>

1. <a name="s3"></a>Use additional CA certificates during keys fetching in `jwks-uri`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

tzheleznyak
tzheleznyak previously approved these changes Dec 27, 2021
Copy link
Contributor

@tzheleznyak tzheleznyak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

benoaviram
benoaviram previously approved these changes Dec 27, 2021
Copy link

@benoaviram benoaviram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sashaCher sashaCher dismissed stale reviews from benoaviram and tzheleznyak via 13ea316 December 27, 2021 08:53
@sashaCher sashaCher force-pushed the authn-jwk-configuration-design branch from 959b682 to 13ea316 Compare December 27, 2021 08:53
Copy link
Contributor

@tzheleznyak tzheleznyak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM2

|[Enforced claims and claim aliases](token_schema.md)|July 18, 2021|
|[`aud` claim support](aud_claim_support.md)|July 29, 2021|
|[Complex token support](complex_token.md)|October 27, 2021|
|[Enhance signing key delivery mechanisms](authn-jwt-fetch-more-keys.md)|December 27, 2021|
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length

| Signing key configuration is invalid: `public-keys` `value` field is missing or empty | When value field absent or has empty value |
</div></details>

1. <a name="s6"></a>Strict JWKS structure input validation
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

</div></details>

1. <a name="s6"></a>Strict JWKS structure input validation
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

</div></details>

1. <a name="s6"></a>Strict JWKS structure input validation
<details><div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline HTML

* `value` - the value of JWKS as is it's returned from unreachable jwks/provider-uri
endpoint.
<details><summary>JSON example</summary>
For example (based on https://www.googleapis.com/oauth2/v3/certs):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bare URL used

@codeclimate
Copy link

codeclimate bot commented Dec 27, 2021

Code Climate has analyzed commit 13ea316 and detected 48 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 48

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 91.0% (0.0% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants