Require HTTPS for OIDC and public URLs; stop logging token responses
Address review findings on a10b24c:
- F1: the OIDC issuer and the discovered authorization, token and JWKS
endpoints must be https://; plain http:// is allowed only for the
loopback hosts localhost, 127.0.0.1 and [::1]. Config rejects a remote
http:// issuer at startup; auth.New rejects a discovered remote http://
endpoint, naming it, before it is used.
- F2: a failed code exchange is reduced to a fixed category plus the HTTP
status; the token endpoint's body and error_description are never logged
or wrapped into the returned error.
- F3: MEALQUEST_PUBLIC_URL must be https:// unless its host is loopback,
so the Secure login cookie is always sent back on the callback.
The rule lives once, in internal/secureurl.Check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -150,6 +150,24 @@ func TestLoad(t *testing.T) {
|
||||
env: with(map[string]string{EnvPublicURL: "http://:8080"}),
|
||||
badVars: []string{EnvPublicURL},
|
||||
},
|
||||
{
|
||||
name: "plain HTTP public URL on a remote host",
|
||||
env: with(map[string]string{EnvPublicURL: "http://meals.example.com"}),
|
||||
badVars: []string{EnvPublicURL},
|
||||
},
|
||||
{
|
||||
name: "plain HTTP public URL on a non-loopback IP",
|
||||
env: with(map[string]string{EnvPublicURL: "http://192.168.1.20:8080"}),
|
||||
badVars: []string{EnvPublicURL},
|
||||
},
|
||||
{
|
||||
name: "plain HTTP public URL on 127.0.0.1",
|
||||
env: with(map[string]string{EnvPublicURL: "http://127.0.0.1:8080"}),
|
||||
},
|
||||
{
|
||||
name: "plain HTTP public URL on [::1]",
|
||||
env: with(map[string]string{EnvPublicURL: "http://[::1]:8080"}),
|
||||
},
|
||||
{
|
||||
name: "relative public URL",
|
||||
env: with(map[string]string{EnvPublicURL: "meals.example.com"}),
|
||||
@@ -200,6 +218,15 @@ func TestLoad(t *testing.T) {
|
||||
env: with(map[string]string{EnvOIDCIssuer: "ftp://auth.example.com"}),
|
||||
badVars: []string{EnvOIDCIssuer},
|
||||
},
|
||||
{
|
||||
name: "plain HTTP OIDC issuer on a remote host",
|
||||
env: with(map[string]string{EnvOIDCIssuer: "http://auth.example.com/application/o/mealquest/"}),
|
||||
badVars: []string{EnvOIDCIssuer},
|
||||
},
|
||||
{
|
||||
name: "plain HTTP OIDC issuer on localhost",
|
||||
env: with(map[string]string{EnvOIDCIssuer: "http://localhost:9000/application/o/mealquest/"}),
|
||||
},
|
||||
{
|
||||
name: "several allowed groups",
|
||||
env: with(map[string]string{EnvOIDCAllowedGroups: "mealquest-admin, family"}),
|
||||
|
||||
Reference in New Issue
Block a user