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

Add performance index for token resolution #2932

Merged
merged 21 commits into from
Jul 15, 2024
Merged

Conversation

strehle
Copy link
Member

@strehle strehle commented Jun 17, 2024

  • add external_key to identity_provider
  • add index and optional search in retrieveByIssuer
  • add external_key for OAuth/OIDC and SAML IdP

Verified on DB level with explain that index is used.

Add unique index with constrains: identity zone, type, external-id, means that you can have a SAML IDP and OIDC IDP with same issuer / entityID. This can happen and should be allowed. What should be prevented to have 2 IdPs with same entityID or issuer in configuration.

To stay compatible, introduce allowAllOrigins option. Currently we loop in REST calls and check uniqueness of issuer/entityId. Admin can decide to remove this loop in some time.

* add external_key to identity_provider
* add index and optional search in retrieveByIssuer
* add external_key for OAuth/OIDC and SAML IdP
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/187807023

The labels on this github issue will be updated when the story is started.

@strehle strehle requested a review from a team June 18, 2024 14:31
strehle added a commit that referenced this pull request Jun 19, 2024
hint: we do not support RFC 7523 on server side.
will come after PR #2932 . We need the index for
resolution of iss in case of support of RFC 7523
only postgres supports them
- shorten the index name. Similar name pattern then existing
strehle added a commit that referenced this pull request Jul 9, 2024
* Fix documentation for OpenID connect clientJWT

hint: we do not support RFC 7523 on server side.
will come after PR #2932 . We need the index for
resolution of iss in case of support of RFC 7523

* update

* review
@hsinn0
Copy link
Contributor

hsinn0 commented Jul 9, 2024

I am a bit concerned about the performance impact for searching by and having a unique index on a text column. Have we done any performance testing for this change?

@strehle
Copy link
Member Author

strehle commented Jul 10, 2024

I am a bit concerned about the performance impact for searching by and having a unique index on a text column. Have we done any performance testing for this change?

yes, of course I have the explain and index is used in both DBs.
The usage of a text in an index is no real difference for postgresql , for mysql the complete text is not usable in index, so you see I had to limit the index usage....
The unique index is the runtime behavior and now visible in DB. so you cannot have 2 IdPs from type SAML with same entityID. Same with OIDC. Only one OIDC IdP with same issuer is possible. We have internal runtime checks with the loop.

The loop over all IdP is configurable because I dont want to change the behavior for all, but we will move to new one.
I created a PR to have all this new behaviors in one place , e.g. #2934 so that users of UAA can decide what type of checks they want have

@strehle strehle requested a review from torsten-sap July 10, 2024 05:44
@strehle
Copy link
Member Author

strehle commented Jul 10, 2024

@torsten-sap Should we limit the size of external id to maybe 512 ?

@hsinn0
Copy link
Contributor

hsinn0 commented Jul 10, 2024

The unique index is the runtime behavior and now visible in DB.

You mean the uniqueness was already being checked in Java runtime, and we are adding the index in DB this time? So there is no added performance degradation with this change in that regard?

@strehle
Copy link
Member Author

strehle commented Jul 10, 2024

The unique index is the runtime behavior and now visible in DB.

You mean the uniqueness was already being checked in Java runtime, and we are adding the index in DB this time? So there is no added performance degradation with this change in that regard?

yes, in OIDC and SAML there are checks, but currently these checks loop. and this is a performance issuer right now ... if you have many IdP, see OIDC runtime as example
https://github.com/cloudfoundry/uaa/blob/develop/server/src/main/java/org/cloudfoundry/identity/uaa/provider/oauth/ExternalOAuthProviderConfigurator.java#L157-L168

I will change the text field into VARCHAR(512) so that mysql does not have an issue with it.
I would like to stay with the unique index because the runtime prevents several issuers / entityId also now.

@strehle
Copy link
Member Author

strehle commented Jul 10, 2024

The unique index is the runtime behavior and now visible in DB.

You mean the uniqueness was already being checked in Java runtime, and we are adding the index in DB this time? So there is no added performance degradation with this change in that regard?

here is the SAML check for duplicate
https://github.com/cloudfoundry/uaa/blob/develop/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/SamlIdentityProviderConfigurator.java#L105-L107

That is the reason why I added the index as unique, because we have the checks in runtime are there but without a performant access and simply via select * in DB.... but this is a problem in case of many IdPs

strehle added a commit to cloudfoundry/uaa-release that referenced this pull request Jul 12, 2024
@strehle strehle requested a review from hsinn0 July 15, 2024 09:34
@strehle
Copy link
Member Author

strehle commented Jul 15, 2024

The unique index is the runtime behavior and now visible in DB.

You mean the uniqueness was already being checked in Java runtime, and we are adding the index in DB this time? So there is no added performance degradation with this change in that regard?

Correct 👍

@strehle strehle merged commit 8ba95b2 into develop Jul 15, 2024
22 checks passed
@strehle strehle deleted the fix/2821/addExternId branch July 15, 2024 18:22
strehle added a commit to cloudfoundry/uaa-release that referenced this pull request Jul 18, 2024
strehle added a commit to cloudfoundry/uaa-release that referenced this pull request Jul 19, 2024
strehle added a commit to cloudfoundry/uaa-release that referenced this pull request Jul 25, 2024
strehle added a commit to cloudfoundry/uaa-release that referenced this pull request Jul 25, 2024
* Add configuration option for origin loop

Depends on PR cloudfoundry/uaa#2932

* Update jobs/uaa/spec

Co-authored-by: Adrian Hölzl <102049638+adrianhoelzl-sap@users.noreply.github.com>

* Update description

Use a more generic description.
This flag should be used later also in /identity-providers GET
to filter this and not return all IdPs

---------

Co-authored-by: Adrian Hölzl <102049638+adrianhoelzl-sap@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Fix performance issue with external identity provider lookup [OIDC]
3 participants