Skip to content
Closed
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
5 changes: 0 additions & 5 deletions internal/authelia/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -136,8 +136,6 @@ func parseOAuth2Scope(raw string) (string, error) {
switch p {
case "openid":
hasOpenID = true
case authelia.PAMScope:
hasPAMScope = true
}
}
}
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Loading