Skip to content

Commit d1d359a

Browse files
authored
Remove ActiveRolesProvider (apache#2390)
Summary of changes: - As proposed on the ML, `ActiveRolesProvider` is removed, and `DefaultActiveRolesProvider` is merged into `DefaultAuthenticator`. `ActiveRolesAugmentor` is also merged into `AuthenticatingAugmentor`. - The implicit convention that no roles in credentials == all roles requested is removed as it is ambiguous. Credentials must explicitly include the `PRINCIPAL_ROLE:ALL` pseudo-role to request all roles available. - PersistedPolarisPrincipal is removed. It existed merely as a means of passing the `PrincipalEntity` from the authenticator to the roles provider. This is not necessary anymore.
1 parent 984cb0f commit d1d359a

File tree

18 files changed

+456
-559
lines changed

18 files changed

+456
-559
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ refresh-credentials flag for the desired storage provider.
101101

102102
### Deprecations
103103

104-
- The property `polaris.active-roles-provider.type` is deprecated for removal.
105-
- The `ActiveRolesProvider` interface is deprecated for removal.
104+
* The property `polaris.active-roles-provider.type` is deprecated and has no effect anymore.
106105

107106
### Fixes
108107

helm/polaris/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ ct install --namespace polaris --charts ./helm/polaris
189189
|-----|------|---------|-------------|
190190
| advancedConfig | object | `{}` | Advanced configuration. You can pass here any valid Polaris or Quarkus configuration property. Any property that is defined here takes precedence over all the other configuration values generated by this chart. Properties can be passed "flattened" or as nested YAML objects (see examples below). Note: values should be strings; avoid using numbers, booleans, or other types. |
191191
| affinity | object | `{}` | Affinity and anti-affinity for polaris pods. See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity. |
192-
| authentication | object | `{"activeRolesProvider":{"type":"default"},"authenticator":{"type":"default"},"realmOverrides":{},"tokenBroker":{"maxTokenGeneration":"PT1H","secret":{"name":null,"privateKey":"private.pem","publicKey":"public.pem","rsaKeyPair":{"privateKey":"private.pem","publicKey":"public.pem"},"secretKey":"symmetric.pem","symmetricKey":{"secretKey":"symmetric.key"}},"type":"rsa-key-pair"},"tokenService":{"type":"default"},"type":"internal"}` | Polaris authentication configuration. |
193-
| authentication.activeRolesProvider | object | `{"type":"default"}` | The `ActiveRolesProvider` implementation to use. Only one built-in type is supported: default. |
192+
| authentication | object | `{"authenticator":{"type":"default"},"realmOverrides":{},"tokenBroker":{"maxTokenGeneration":"PT1H","secret":{"name":null,"privateKey":"private.pem","publicKey":"public.pem","rsaKeyPair":{"privateKey":"private.pem","publicKey":"public.pem"},"secretKey":"symmetric.pem","symmetricKey":{"secretKey":"symmetric.key"}},"type":"rsa-key-pair"},"tokenService":{"type":"default"},"type":"internal"}` | Polaris authentication configuration. |
194193
| authentication.authenticator | object | `{"type":"default"}` | The `Authenticator` implementation to use. Only one built-in type is supported: default. |
195194
| authentication.realmOverrides | object | `{}` | Authentication configuration overrides per realm. |
196195
| authentication.tokenBroker | object | `{"maxTokenGeneration":"PT1H","secret":{"name":null,"privateKey":"private.pem","publicKey":"public.pem","rsaKeyPair":{"privateKey":"private.pem","publicKey":"public.pem"},"secretKey":"symmetric.pem","symmetricKey":{"secretKey":"symmetric.key"}},"type":"rsa-key-pair"}` | The `TokenBroker` implementation to use. Two built-in types are supported: rsa-key-pair and symmetric-key. Only relevant when using internal (or mixed) authentication. When using external authentication, the token broker is not used. |
@@ -299,7 +298,7 @@ ct install --namespace polaris --charts ./helm/polaris
299298
| oidc.principalMapper.type | string | `"default"` | The `PrincipalMapper` implementation to use. Only one built-in type is supported: default. |
300299
| oidc.principalRolesMapper | object | `{"filter":null,"mappings":[],"rolesClaimPath":null,"type":"default"}` | Principal roles mapping configuration. |
301300
| oidc.principalRolesMapper.filter | string | `nil` | A regular expression that matches the role names in the identity. Only roles that match this regex will be included in the Polaris-specific roles. |
302-
| oidc.principalRolesMapper.mappings | list | `[]` | A list of regex mappings that will be applied to each role name in the identity. This can be used to transform the role names in the identity into role names as expected by Polaris. The default ActiveRolesProvider expects the security identity to expose role names in the format `POLARIS_ROLE:<role name>`. |
301+
| oidc.principalRolesMapper.mappings | list | `[]` | A list of regex mappings that will be applied to each role name in the identity. This can be used to transform the role names in the identity into role names as expected by Polaris. The default Authenticator expects the security identity to expose role names in the format `POLARIS_ROLE:<role name>`. |
303302
| oidc.principalRolesMapper.rolesClaimPath | string | `nil` | The path to the claim that contains the principal roles. Nested paths can be expressed using "/" as a separator, e.g. "polaris/principal_roles" would look for the "principal_roles" field inside the "polaris" object in the token claims. If not set, Quarkus looks for roles in standard locations. See https://quarkus.io/guides/security-oidc-bearer-token-authentication#token-claims-and-security-identity-roles. |
304303
| oidc.principalRolesMapper.type | string | `"default"` | The `PrincipalRolesMapper` implementation to use. Only one built-in type is supported: default. |
305304
| persistence | object | `{"relationalJdbc":{"secret":{"jdbcUrl":"jdbcUrl","name":null,"password":"password","username":"username"}},"type":"in-memory"}` | Polaris persistence configuration. |

helm/polaris/ci/authentication-values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ authentication:
3131
type: internal
3232
authenticator:
3333
type: default
34-
activeRolesProvider:
35-
type: default
3634
tokenService:
3735
type: default
3836
tokenBroker:

helm/polaris/templates/_helpers.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ Sets the configmap authentication options for a given realm.
316316
{{- end -}}
317317
{{- $_ := set $map (printf "%s.type" $prefix) $authType -}}
318318
{{- $_ = set $map (printf "%s.authenticator.type" $prefix) (dig "authenticator" "type" "default" $auth) -}}
319-
{{- $_ = set $map (printf "%s.active-roles-provider.type" $prefix) (dig "activeRolesProvider" "type" "default" $auth) -}}
320319
{{- if (or (eq $authType "mixed") (eq $authType "internal")) -}}
321320
{{- $tokenBrokerType := dig "tokenBroker" "type" "rsa-key-pair" $auth -}}
322321
{{- $_ = set $map (printf "%s.token-service.type" $prefix) (dig "tokenService" "type" "default" $auth) -}}

helm/polaris/tests/configmap_test.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,6 @@ tests:
168168
asserts:
169169
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.authenticator.type=custom" }
170170

171-
- it: should configure default active roles provider
172-
set: { authentication: { activeRolesProvider: { type: default } } }
173-
asserts:
174-
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.active-roles-provider.type=default" }
175-
176-
- it: should configure custom active roles provider
177-
set: { authentication: { activeRolesProvider: { type: custom } } }
178-
asserts:
179-
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.active-roles-provider.type=custom" }
180-
181171
- it: should configure default token service
182172
set: { authentication: { tokenService: { type: default } } }
183173
asserts:
@@ -209,18 +199,16 @@ tests:
209199
set:
210200
authentication:
211201
realmOverrides:
212-
realm1: { type: mixed, authenticator: { type: custom1 }, activeRolesProvider: { type: custom1 }, tokenBroker: { type: custom1 }, tokenService: { type: custom1 } }
213-
realm2: { type: external, authenticator: { type: custom2 }, activeRolesProvider: { type: custom2 } }
202+
realm1: { type: mixed, authenticator: { type: custom1 }, tokenBroker: { type: custom1 }, tokenService: { type: custom1 } }
203+
realm2: { type: external, authenticator: { type: custom2 } }
214204
"REALM 3": { type: internal, tokenBroker: { type: rsa-key-pair, secret: { name: polaris-auth } } }
215205
asserts:
216206
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm1\".type=mixed" }
217207
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm1\".authenticator.type=custom1" }
218-
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm1\".active-roles-provider.type=custom1" }
219208
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm1\".token-broker.type=custom1" }
220209
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm1\".token-service.type=custom1" }
221210
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm2\".type=external" }
222211
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm2\".authenticator.type=custom2" }
223-
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"realm2\".active-roles-provider.type=custom2" }
224212
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"REALM\\\\ 3\".type=internal" }
225213
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"REALM\\\\ 3\".token-broker.type=rsa-key-pair" }
226214
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.authentication.\"REALM\\\\ 3\".token-broker.rsa-key-pair.public-key-file=/deployments/config/REALM\\+3/public.pem" }

helm/polaris/values.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,6 @@ authentication:
580580
# -- The `Authenticator` implementation to use. Only one built-in type is supported: default.
581581
authenticator:
582582
type: default
583-
# -- The `ActiveRolesProvider` implementation to use. Only one built-in type is supported: default.
584-
activeRolesProvider:
585-
type: default
586583
# -- The token service (`IcebergRestOAuth2ApiService`) implementation to use. Two built-in types are supported: default and disabled.
587584
# Only relevant when using internal (or mixed) authentication. When using external authentication, the token service is always disabled.
588585
tokenService:
@@ -671,7 +668,7 @@ oidc:
671668
filter: ~ # ^(?!profile$|email$).*
672669
# -- A list of regex mappings that will be applied to each role name in the identity. This can
673670
# be used to transform the role names in the identity into role names as expected by Polaris.
674-
# The default ActiveRolesProvider expects the security identity to expose role names in the
671+
# The default Authenticator expects the security identity to expose role names in the
675672
# format `POLARIS_ROLE:<role name>`.
676673
mappings: []
677674
# - regex: role_(.*)

runtime/defaults/src/main/resources/application.properties

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,12 @@ polaris.rate-limiter.token-bucket.type=default
150150
polaris.rate-limiter.token-bucket.requests-per-second=9999
151151
polaris.rate-limiter.token-bucket.window=PT10S
152152

153-
# This property is DEPRECATED for removal; use polaris.authentication.active-roles-provider.type instead
154-
polaris.active-roles-provider.type=default
155-
156153
# Polaris authentication settings
157154
polaris.authentication.type=internal
158155
polaris.authentication.authenticator.type=default
159-
polaris.authentication.active-roles-provider.type=${polaris.active-roles-provider.type}
160156
# Per-realm overrides:
161157
# polaris.authentication.realm1.type=external
162158
# polaris.authentication.realm1.authenticator.type=custom
163-
# polaris.authentication.realm1.active-roles-provider.type=custom
164159

165160
# Options effective when using internal auth (can be overridden in per realm):
166161
polaris.authentication.token-service.type=default

runtime/service/src/main/java/org/apache/polaris/service/auth/ActiveRolesAugmentor.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

runtime/service/src/main/java/org/apache/polaris/service/auth/ActiveRolesProvider.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

runtime/service/src/main/java/org/apache/polaris/service/auth/AuthenticatingAugmentor.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@ private SecurityIdentity authenticatePolarisPrincipal(
7272
SecurityIdentity identity, PolarisCredential polarisCredential) {
7373
try {
7474
PolarisPrincipal polarisPrincipal = authenticator.authenticate(polarisCredential);
75-
return QuarkusSecurityIdentity.builder(identity).setPrincipal(polarisPrincipal).build();
75+
QuarkusSecurityIdentity.Builder builder =
76+
QuarkusSecurityIdentity.builder()
77+
.setAnonymous(false)
78+
.setPrincipal(polarisPrincipal)
79+
.addRoles(polarisPrincipal.getRoles())
80+
.addCredentials(identity.getCredentials())
81+
.addAttributes(identity.getAttributes())
82+
.addPermissionChecker(identity::checkPermission);
83+
// Also include the Polaris principal properties as attributes of the identity
84+
polarisPrincipal.getProperties().forEach(builder::addAttribute);
85+
return builder.build();
7686
} catch (RuntimeException e) {
7787
throw new AuthenticationFailedException(e);
7888
}

0 commit comments

Comments
 (0)