Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

louismariegaborit
Copy link
Contributor

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Add support for RSA signature algorithm for OidcTokenHandler.
Amazon Cognito uses RS256 algorithm for its tokens.

@carsonbot carsonbot added this to the 7.1 milestone Jan 30, 2024
@louismariegaborit louismariegaborit force-pushed the security_support_rsa branch 3 times, most recently from bc94265 to 9c46285 Compare January 30, 2024 12:49
@nicolas-grekas nicolas-grekas changed the title [Security] Support RSA algorithm signature [Security] Support RSA algorithm signature for OIDC tokens Jan 30, 2024
@louismariegaborit louismariegaborit force-pushed the security_support_rsa branch 3 times, most recently from 84e1317 to 6b4e728 Compare January 30, 2024 13:10
@Spomky
Copy link
Contributor

Spomky commented Feb 1, 2024

Hi,

Is it possible to put this PR on hold?
The reason is that algorithms from the web-token/ suite will be grouped and, very soon, with web-token/jwt-library you will have all at once (including encryption to help #50441)

@Spomky
Copy link
Contributor

Spomky commented Feb 1, 2024

Hi @louismariegaborit,

Can you test with "web-token/jwt-library": "3.3.0@dev" adn "ext-openssl": "*"?
Both web-token/jwt-signature-algorithm-ecdsa and web-token/jwt-signature-algorithm-rsa dependencies can be removed.

Also, because the new web-token/jwt-library contains more than ESxxx and RSxxx algorithms, I am wondering if this PR could be renamed to [Security] Support any signature algorithms for OIDC tokens and allow developers picking the algorthims they need.

Note: web-token/jwt-library will be tagged in a couple of days.

@louismariegaborit
Copy link
Contributor Author

louismariegaborit commented Feb 1, 2024

Hi @Spomky

This seems ok. I removed also web-token/jwt-checker.
For the ext-openssl, I added it in the require-dev but it's in suggest like in your repository that you want that be added ?

I will look so that developers picked the algorithms they need.

I will update the PR title when we validate the work.

@louismariegaborit
Copy link
Contributor Author

@Spomky I did a try. WDYT ?
I don't know if I can delete old algorithm services without deprecations. And if I keep the services with deprecations, could you tell me how do it ?

@Spomky
Copy link
Contributor

Spomky commented Feb 2, 2024

This seems ok. I removed also web-token/jwt-checker.
For the ext-openssl, I added it in the require-dev but it's in suggest like in your repository that you want that be added ?

Indeed, most of jwt-* packages are now under jwt-library.
OK for ext-openssl in the required-dev section. I'll make sure the algorithms complain if it's missing.


@vincentchalamon do you have any recommendation to have a better algorithm support architecture.
What could be interesting is to allow multiple algorithms

# config/packages/security.yaml
security:
    firewalls:
        main:
            access_token:
                token_handler:
                    oidc:
                        # Algorithms used to sign the JWS
                        algorithms:
                            - 'ES256'
                            - 'RS256'
                            - 'PS256'
                        # A JSON-encoded JWK
                        key: '{"kty":"...","k":"..."}'

From my understanding, it will require:

  • If the configuraition key algorithm is present: to normaliwe the current configuration fro; ["algorithm" => $alg] to ["algorithms" => [$alg]]
  • Change the OidcTokenHandler first argument to accept an algorithm manager object instead a single algorithm
  • Use the algorithm manager factory to create the algorithm manager according to the configuration

Any ideas on this?

@louismariegaborit
Copy link
Contributor Author

@vincentchalamon do you have any recommendation to have a better algorithm support architecture. What could be interesting is to allow multiple algorithms

# config/packages/security.yaml
security:
    firewalls:
        main:
            access_token:
                token_handler:
                    oidc:
                        # Algorithms used to sign the JWS
                        algorithms:
                            - 'ES256'
                            - 'RS256'
                            - 'PS256'
                        # A JSON-encoded JWK
                        key: '{"kty":"...","k":"..."}'

From my understanding, it will require:

  • If the configuraition key algorithm is present: to normaliwe the current configuration fro; ["algorithm" => $alg] to ["algorithms" => [$alg]]
  • Change the OidcTokenHandler first argument to accept an algorithm manager object instead a single algorithm
  • Use the algorithm manager factory to create the algorithm manager according to the configuration

Any ideas on this?

@Spomky I started this work in another PR (#51665).
I still need to support an array for the algorithms.
I think, we must decide what is the responsability of each PR.

@vincentchalamon
Copy link
Contributor

@Spomky on an OIDC server (e.g.: Keycloak), is it possible to allow multiple algorithms on a single realm?

If true, multiple algorithms configuration could be interesting, indeed. I'm just wondering if the key configuration (JWK) shouldn't be associated to the corresponding algorithm, as I think they're linked (cf. JWA).

If false, I don't think we should allow multiple algorithms configuration as multiple realms are not supported.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM with minor CS fixes

@Spomky Spomky force-pushed the security_support_rsa branch from 0faa51a to b179b40 Compare March 24, 2024 13:00
chalasr
chalasr previously approved these changes Mar 24, 2024
@chalasr chalasr dismissed their stale review March 24, 2024 19:21

Some tests are broken due to this change

Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

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

Can you look at failing tests?

@Spomky Spomky force-pushed the security_support_rsa branch 3 times, most recently from 949281a to d930172 Compare March 24, 2024 20:56
@Spomky
Copy link
Contributor

Spomky commented Mar 24, 2024

Hi @chalasr,

It seems to be fine now.
I corrected one of the tests without the @group legacy. Other errors are not related to this PR.

@chalasr chalasr force-pushed the security_support_rsa branch from 15b26b2 to 0a87377 Compare March 24, 2024 22:50
@nicolas-grekas nicolas-grekas added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label Apr 2, 2024
@chalasr chalasr force-pushed the security_support_rsa branch from 0a87377 to 3109350 Compare April 3, 2024 10:12
@chalasr
Copy link
Member

chalasr commented Apr 3, 2024

Thank you @louismariegaborit and @Spomky.

@chalasr chalasr merged commit 09437dc into symfony:7.1 Apr 3, 2024
@louismariegaborit louismariegaborit deleted the security_support_rsa branch April 3, 2024 19:44
@fabpot fabpot mentioned this pull request May 2, 2024
@xabbuh xabbuh mentioned this pull request May 24, 2024
xabbuh added a commit that referenced this pull request May 24, 2024
This PR was merged into the 7.1 branch.

Discussion
----------

remove empty PHP file

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | related to #53682
| License       | MIT

Commits
-------

2e894f8 remove empty PHP file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Security ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants