Skip to content

Add placeholder replacement support for signKey #92

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

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

steffenbusch
Copy link
Contributor

This pull request adds placeholder replacement support for the sign_key sub-directive, allowing users to load keys from external files.

Example usage:

jwtauth {
  sign_key {file.sign_key.txt}
  sign_alg HS256
  jwk_url https://api.example.com/jwk/keys
  from_query access_token token
  from_header X-Api-Token
  from_cookies user_session
  issuer_whitelist https://api.example.com
  audience_whitelist https://api.example.io https://learn.example.com
  user_claims aud uid user_id username login
  meta_claims "IsAdmin->is_admin" "settings.payout.paypal.enabled->is_paypal_enabled"
}

In this example, the file sign_key.txt contains the actual signing key, such as:

TkZMNSowQmMjOVU2RUB0bm1DJkU3U1VONkd3SGZMbVk=

This update also facilitates the use of public keys by allowing direct references to .pem files, e.g.:

sign_key {file./path/to/public_key.pem}

Note
This feature requires Caddy v2.8.0 or later, which introduced support for the {file.} placeholder syntax.
See: caddyserver/caddy#5463

@ggicci ggicci merged commit a248851 into ggicci:main Mar 25, 2025
1 check failed
@ggicci
Copy link
Owner

ggicci commented Mar 25, 2025

Thank you @steffenbusch :)

@steffenbusch steffenbusch deleted the placeholder-support branch March 29, 2025 08:25
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