Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ environment variables is used in this image:
* `OID_DISCOVERY`: OpenID provider well-known discovery URL
* `OID_CLIENT_ID`: OpenID Client ID
* `OID_CLIENT_SECRET`: OpenID Client Secret
* `OID_CLIENT_SECRET_FILE`: File to pull the OpenID Client Secret from (i.e. if you don't want to store it in an environment variable)
* `OIDC_AUTH_METHOD`: OpenID Connect authentication method (`client_secret_basic` or `client_secret_post`)
* `OIDC_RENEW_ACCESS_TOKEN_ON_EXPIERY`: Enable silent renew of access token (`true` or `false`)

Expand Down
1 change: 1 addition & 0 deletions nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env OID_SESSION_NAME;
env OID_DISCOVERY;
env OID_CLIENT_ID;
env OID_CLIENT_SECRET;
env OID_CLIENT_SECRET_FILE;
env OID_REDIRECT_PATH;
env OIDC_AUTH_SCOPE;
env OIDC_AUTH_METHOD;
Expand Down
18 changes: 17 additions & 1 deletion nginx/lua/auth.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
if os.getenv("OID_CLIENT_SECRET_FILE") then
filename = os.getenv("OID_CLIENT_SECRET_FILE")
local f = io.open(filename, "rb")
if not f then
ngx.status = 500
ngx.header.content_type = 'text/html';

ngx.say("Could not find filename for OID_CLIENT_SECRET_FILE: " .. filename)
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end

oid_secret = f.read(f)
else
oid_secret = os.getenv("OID_CLIENT_SECRET")
end

local opts = {
redirect_uri_path = os.getenv("OID_REDIRECT_PATH") or "/redirect_uri",
discovery = os.getenv("OID_DISCOVERY"),
client_id = os.getenv("OID_CLIENT_ID"),
client_secret = os.getenv("OID_CLIENT_SECRET"),
client_secret = oid_secret,
token_endpoint_auth_method = os.getenv("OIDC_AUTH_METHOD") or "client_secret_basic",
renew_access_token_on_expiry = os.getenv("OIDC_RENEW_ACCESS_TOKEN_ON_EXPIERY") ~= "false",
scope = os.getenv("OIDC_AUTH_SCOPE") or "openid",
Expand Down