Skip to content

[BUG] Creating an OIDC client with a hyphen in its name generates invalid systemd environment variables #1130

Description

@LukasSkywalker

Describe the Bug

Creating a new OIDC client via the command line tries to turn the client name into an environment variable. If the name contains a hyphen, this name is turned into a variable name with a hyphen similar to this: TINYAUTH_OIDC_CLIENTS_MY-APP_CLIENTID.
When the variable is placed in a file and loaded via systemds EnvironmentFile=, lines with variable names containing hyphens are ignored: https://man7.org/linux/man-pages/man5/systemd.exec.5.html#ENVIRONMENT
Disallowing hyphens would fix that issue.

How to Reproduce

  1. Run ./tinyauth oidc create my-app
  2. It displays the environment variable TINYAUTH_OIDC_CLIENTS_MY-APP_CLIENTID
  3. When running tinyauth via systemd, this variable is ignored and OIDC does not work.

Expected Behavior

It should display an error, because an environment variable with a dash is invalid in systemd.

Additional Context

The variables are ignored when they contain a hyphen:

root@tinyauth:~# cat /opt/tinyauth/.env
TINYAUTH_DATABASE_PATH=/opt/tinyauth/database.db
TINYAUTH_AUTH_USERS='foo@example.com:$$2a$$10$$redacted123'
TINYAUTH_APPURL=https://auth.example.com
TINYAUTH_OIDC_CLIENTS_MY-APP_CLIENTID=foo
TINYAUTH_OIDC_CLIENTS_MY-APP_CLIENTSECRET=bar
TINYAUTH_OIDC_CLIENTS_MY-APP_NAME=baz

root@tinyauth:~# systemd-run --wait --pipe -p EnvironmentFile=/opt/tinyauth/.env /usr/bin/env | grep -o '^TINYAUTH_[^=]*'
Running as unit: run-p847-i2375553.service; invocation ID: 8bb8043490f3415a8ba4744f5cad4918
TINYAUTH_DATABASE_PATH
TINYAUTH_AUTH_USERS
TINYAUTH_APPURL
Finished with result: success

But are kept when they don't:

root@tinyauth:~# cat /opt/tinyauth/.env 
TINYAUTH_DATABASE_PATH=/opt/tinyauth/database.db
TINYAUTH_AUTH_USERS='foo@example.com:$$2a$$10$$redacted123'
TINYAUTH_APPURL=https://auth.example.com
TINYAUTH_OIDC_CLIENTS_MYAPP_CLIENTID=foo
TINYAUTH_OIDC_CLIENTS_MYAPP_CLIENTSECRET=bar
TINYAUTH_OIDC_CLIENTS_MYAPP_NAME=baz

root@tinyauth:~# systemd-run --wait --pipe -p EnvironmentFile=/opt/tinyauth/.env /usr/bin/env | grep -o '^TINYAUTH_[^=]*'
Running as unit: run-p854-i2400855.service; invocation ID: de43d415f7234abcbb7c6cf87057f311
TINYAUTH_DATABASE_PATH
TINYAUTH_AUTH_USERS
TINYAUTH_APPURL
TINYAUTH_OIDC_CLIENTS_MYAPP_CLIENTID
TINYAUTH_OIDC_CLIENTS_MYAPP_CLIENTSECRET
TINYAUTH_OIDC_CLIENTS_MYAPP_NAME
Finished with result: success

Logs

No response

Operating System

Linux

Browser

No response

Tinyauth Version

v5.2.0

Docker Version (if applicable)

No response

Human Written Confirmation

  • I confirm this issue was written by me and not generated by an LLM or AI assistant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions