Allow bypassing permissions check on public/private key files

Created on 17 December 2018, over 5 years ago
Updated 21 August 2023, 10 months ago

Problem/Motivation

Simple OAuth requires you to create public.key and private.key files. The League/OAuth2 library it uses requires those to have permissions of 400, 440, 600, or 660. This can cause issues in rare situations where setting the files to one of those permissions isn't possible.

For example when using Pantheon, the module lets you generate the keys in the sites/default/files/private directory, and tries to set them to 600, but something on the host side is enforcing a different and non-compatible set of file permissions. If you know what you're doing, and are comfortable for whatever reason bypassing these permissions it would be nice if there was a setting to be able to do.

Proposed resolution

Add a service container configuration flag:

parameters:
  simple_oauth.config:
    bypass_key_permission_check_UNSAFE: true

This keeps the option relatively hidden, people will likely try and resolve it by doing the correct thing first and change file permissions. But, if that's not an option and they start digging into the code to see if there's a setting or something (like I did) they're will be. Woot!

Then, when it's set, anytime we use either the private or public key in a way that would cause \League\OAuth2\Server\CryptKey to trigger it's permissions check, instead create our own instance of \League\OAuth2\Server\CryptKey and set the "check permissions" constructor argument to false.

It looks like were we currently pass the path to the key file, you can also pass an instance of \League\OAuth2\Server\CryptKey instead.

✨ Feature request
Status

Fixed

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eojthebrave Minneapolis, MN

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024