Skip to content

PS 10999 8.4 OIDC authentication#5941

Open
jankowsk wants to merge 6 commits into
percona:8.4from
jankowsk:PS-10999-8.4-OIDC_Authentication
Open

PS 10999 8.4 OIDC authentication#5941
jankowsk wants to merge 6 commits into
percona:8.4from
jankowsk:PS-10999-8.4-OIDC_Authentication

Conversation

@jankowsk
Copy link
Copy Markdown
Contributor

No description provided.

@jankowsk jankowsk requested a review from lukin-oleksiy May 11, 2026 09:15
@jankowsk jankowsk force-pushed the PS-10999-8.4-OIDC_Authentication branch 3 times, most recently from f8b2007 to 9df8db7 Compare May 20, 2026 07:52
@jankowsk jankowsk force-pushed the PS-10999-8.4-OIDC_Authentication branch 8 times, most recently from 1b4c342 to b10ec38 Compare May 21, 2026 07:51
@jankowsk jankowsk requested a review from catalinbp May 21, 2026 09:48
@jankowsk jankowsk force-pushed the PS-10999-8.4-OIDC_Authentication branch 6 times, most recently from f373aeb to fdaa978 Compare May 27, 2026 14:57

###################### INIT #######################
--echo ### INITIALIZE TESTS
--let $IDP_URL = https://keycloak.int.percona.com/realms/master/protocol/openid-connect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will likely change in the future and, for example in jenkins may be different. I wonder if there's a better way to handle this. At least as a first step I would try to reduce the 4 places where we reference this link to only one.

Copy link
Copy Markdown
Contributor Author

@jankowsk jankowsk May 30, 2026

Choose a reason for hiding this comment

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

The keycloak host appears 2 times in the tests and 2 times in config.

Regarding the tests: if we use a variable it can be defined

  1. in "inc" file, we spare 1 occurrence.
  2. as a envvar set before running mtr or passed as some parameter to mtr script -seems that LDAP plugin does that, but this complicates how the tests are called
  3. the above may be partially solved by setting a default value in mtr script (I'd prefer not to touch it more than necessary) or in tests (we are back to point 1 actually).

Regarding the config: well, a Perl snippet replacing the host placeholders in the config could be written. Then enhanced config is saved, used by the plugin and removed at the end of the tast. Doable, but a bit an overkill.

On the other hand, changing the host in future means grep and replace at 4 places. Also as I remember from implementing LDAP or AWS stuff in Oracle nobody worried about hardcoding URLS in tests.

I'd prefer doing nothing or point 1 only, but I'm open for discussion.

Comment thread .gitmodules
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if the repo is taken down or renamed? (highly unlikely but still a possibility) I think the repo should be cloned into Percona-Lab and we should reference that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably you are right, but I'd like to discuss it wider.
On the one hand, by cloning we may miss some important updates (note, that it is a security fragile stuff). On the second hand, the core security functionality is in OpenSSL (like signature verification) used by jwt-cpp.

Comment thread mysql-test/suite/auth_openid_connect/t/auth.test
Comment thread mysql-test/suite/auth_openid_connect/t/auth.test Outdated
Comment thread plugin/auth_openid_connect/src/config.cc Outdated
Comment thread plugin/auth_openid_connect/src/jwks.h
Comment thread plugin/auth_openid_connect/src/plugin_openid_connect.cc Outdated
Comment thread sql/threadpool_unix.cc Outdated
Comment thread plugin/auth_openid_connect/tools/create_id_token.cc Outdated
Comment thread plugin/auth_openid_connect/src/plugin_openid_connect.cc
Comment thread plugin/auth_openid_connect/tools/create_id_token.cc
roles += role;
}
} else if (groups_claim.get_type() == jwt::json::type::string) {
roles = groups_claim.as_string();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't this an issue as above you to idp.get_role?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could you explain?

Copy link
Copy Markdown
Contributor

@catalinbp catalinbp left a comment

Choose a reason for hiding this comment

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

.

@jankowsk jankowsk force-pushed the PS-10999-8.4-OIDC_Authentication branch from fdaa978 to a0f563b Compare May 28, 2026 12:37
jankowsk added 6 commits May 30, 2026 13:37
…oles

When OpenID Connect authentication maps external roles during login,
acl_authenticate() called grant_role() with mpvio->acl_user. That
ACL_USER is a copy allocated on the connection's mem_root and is freed
when dispatch_command() ends.

grant_role() stores ACL_USER by value in the role graph, including the
raw user/host pointers. Later DROP USER walks that graph and reads those
pointers after the mem_root was cleared, causing a heap-use-after-free
(ASAN failure in auth_openid_connect.idp cleanup).

Fix: lookup the durable ACL cache entry with find_acl_user() and pass that
to grant_role() instead of the mem_root copy.

The same problem probably would occur with any other plugin granting roles.
Upstream added OIDC authentication in 9.x, by this commit
the client side plugin is backported to 8.4.

Follow up of WL#16269 OpenID Connect (Oauth2 - JWT) Authentication Support

Change-Id in upstream: I11944643d4a6098312edd16550c0160e86905063

The upstream commit introduces client side OpenID Connect authentication
plugin to MySQL 9.x. Here we port it to 8.4 as part of work on Percona
OpenID Connect authentication.
@jankowsk jankowsk force-pushed the PS-10999-8.4-OIDC_Authentication branch from a0f563b to b827469 Compare May 30, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants