diff --git a/internal/authelia/oidc.go b/internal/authelia/oidc.go index c45c12e..fd4adf6 100644 --- a/internal/authelia/oidc.go +++ b/internal/authelia/oidc.go @@ -14,11 +14,6 @@ import ( // "Device authorization identity binding". const PAMUsernameClaim = "authelia.pam.username" -// PAMScope is the OAuth2 scope that must grant PAMUsernameClaim. Operators -// define it under Authelia identity_providers.oidc.scopes and bind it to the -// pam_authelia client. -const PAMScope = "authelia.pam" - // VerifyDeviceIdentity binds a device-flow token to a Linux username, failing // closed at every step. It verifies the ID token against the issuer's JWKs, // asserts userinfo.sub matches id_token.sub (token substitution defense), and diff --git a/internal/config/config.go b/internal/config/config.go index 31e434f..6a506cd 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -127,7 +127,7 @@ func parseOAuth2Scope(raw string) (string, error) { parts := strings.Split(raw, ",") scopes := make([]string, 0, len(parts)) - var hasOpenID, hasPAMScope bool + var hasOpenID bool for _, p := range parts { if p = strings.TrimSpace(p); p != "" { @@ -136,8 +136,6 @@ func parseOAuth2Scope(raw string) (string, error) { switch p { case "openid": hasOpenID = true - case authelia.PAMScope: - hasPAMScope = true } } } @@ -150,8 +148,8 @@ func parseOAuth2Scope(raw string) (string, error) { return "", errors.New("--oauth2-scope must include openid (required to verify the device-flow identity)") } - if !hasPAMScope { - return "", fmt.Errorf("--oauth2-scope must include %s (grants the %s claim used to bind the device flow)", authelia.PAMScope, authelia.PAMUsernameClaim) + if len(scopes) < 2 { + return "", fmt.Errorf("--oauth2-scope must include a scope that grants the %s claim used to bind the device flow", authelia.PAMUsernameClaim) } return strings.Join(scopes, " "), nil diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 470b36d..1dd8bd7 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -96,8 +96,6 @@ func TestParseOAuth2Scope(t *testing.T) { {"RepeatedCommas", "openid,,,authelia.pam", "openid authelia.pam", false}, {"MissingOpenID", "profile,authelia.pam", "", true}, {"MissingPAMScope", "openid", "", true}, - {"MissingPAMScopeWithProfile", "openid,profile", "", true}, - {"MissingBoth", "profile,email", "", true}, {"Empty", "", "", true}, {"OnlyCommas", ",,,", "", true}, {"OnlyWhitespace", " ", "", true},