-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Accept key content directly instead of require a key file #1007
Comments
We are also running a non-root containerized environment with read-only file systems. But I agree, the library should just take a full key and not try to save it as a file. It tries to coerce you to handle the key safely but the method it uses does not play well with containerized environments. Personally I would ditch all code trying to manage how the key is delivered to the library, maybe only accept strings as keys, not as file paths, and only validate if that string looks like an rsa key. What you can do to handle this without changing the library This can be configured to work nicely with docker-compose and other local tooling too of course. |
Thanks for the suggestion @marc-mabe. We've just released a new major version and as this would be a BC change, it would be a while before we'd get this into the system. As time goes by, I'm wondering more and more if we should have a .env file for the server for all these small options to make them easier to configure such as PKCE enablement, keys etc. I will mark this as a future feature for the timebeing but don't think we can implement this just now. Thanks for the suggestion though. It's very much appreciated. |
I would be strongly against using a What can be done however is look at what types of key formatting the library accepts as input. The current library used for creating JWTs is Recently I came across JWT Framework which seems to have a very good grasp on the standards and expands on the capabilities in Feed the library with json strings; Example json formatting and cli helper commands; It would add different/more dependencies however.
|
Trying to collect context regarding this and related problem spaces/issues: With the addition of |
To the original comment, in For now it makes us stick to 8.1.*, where it's still possible to provide your own implementation of |
The upgrade to php 8 wasn't plain sailing as we didn't want to break BC but the jwt package needed to be a major upgrade. Unfortunately this was one of the compromises. I will take a look but might need to release a proper solution for v9. Sorry for any inconvenience caused by this. |
I have an update in #1180 that switches from using |
Is it worth closing this issue, given recent versions of the library do support fileless keys (with Lcobucci's InMemory)? |
Just confirmed that newer versions do read from env vars @Sephster. |
I am 90 percent certain this is no longer an issue. You don't need a key file as you can pass in a key string which is then stored in memory. You can get this from a .env file if you wish. I can't check this just now @JackKora but see issue #1180 which I think resolved this. It is mentioned 2 comments above and someone also states this probably resolves this issue. As soon as I am able, I will check this and close the ticket accordingly |
We are running the server in a docker environment with read-only filesystem and we use the same docker image for staging and production.
That's why we configure everything (including keys) using environment variables but this is impossible because the keys are required to be available as files :(
Furthermore you already accept the keys as content but in this case you write them to the filesystem (fails in my case because of r/o filesystem) just to get read again by
Lcobucci\JWT\Signer\Key
.Interestingly
Lcobucci\JWT\Signer\Key
does accept the key content directly and only tries to read it as file if it starts withfile://
.As a simple test I have updated
League\OAuth2\Server\CryptKey
constructor to just take the given key as is in case of matchingRSA_KEY_PATTERN
and it worked fine for me.... It's already a bit misleading that
$keyPath
accepts key content (was the case before) but nowgetKeyPath()
also returns the key content in this case.I would suggest to:
$keyPath
to$key
and document it accepts both, a file path and key conentgetKeyPath
getKey()
documented as either key content or file pathThoughts?
The text was updated successfully, but these errors were encountered: