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

[Bug]: Public keys passed to add machine key are not stored in the database #7948

Open
2 tasks done
aDogCalledSpot opened this issue May 14, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@aDogCalledSpot
Copy link
Contributor

aDogCalledSpot commented May 14, 2024

Preflight Checklist

  • I could not find a solution in the documentation, the existing issues or discussions
  • I have joined the ZITADEL chat

Environment

Self-hosted

Version

2.51.0

Database

PostgreSQL

Database Version

16

Describe the problem caused by this bug

When attempting to log in after adding a machine key as implemented in #7671, the call fails with the error message:

msg="request error" oidc_error.parent="invalid signature (error fetching keys: Not Found: ErrorType=invalid_request Description=Errors.AuthNKey.NotFound Parent=ID=QUERY-SDf32 Message=Errors.AuthNKey.NotFound Parent=(sql: no rows in result set))" oidc_error.description="assertion invalid" oidc_error.type=invalid_request status_code=400

To reproduce

  • Add a machine key with a locally generated private key
    • openssl genrsa -out key.pem 2048
    • openssl rsa -in key.pem -pubout > key.pub
  • Attempt to log in the service user using key.pem

Screenshots

No response

Expected behavior

The log in works.

Operating System

No response

Relevant Configuration

No response

Additional Context

The issue definitely stems from #7671, however I'm not sure where something is missing.

The key is added successfully and is visible in the frontend so I'm assuming that the public key isn't copied into the database. I don't know where the necessary changes would have to be made to make sure the key is synced into the database.

@aDogCalledSpot aDogCalledSpot added the bug Something isn't working label May 14, 2024
@aDogCalledSpot
Copy link
Contributor Author

@livio-a do you maybe have a hunch of what might be causing this issue?

@livio-a
Copy link
Member

livio-a commented May 28, 2024

@aDogCalledSpot do you pass the key id as kid in the header?
https://zitadel.com/docs/apis/openidoauth/authn-methods#jwt-with-private-key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants