Compare commits

...

3 Commits

Author SHA1 Message Date
Christian Schwarz
8f5ac73c17 Merge remote-tracking branch 'origin/main' into allow-tenant_create-with-tenant-token
(Minor) Conflicts:
    pageserver/src/http/routes.rs
    test_runner/regress/test_auth.py
2023-06-12 10:49:29 +02:00
Heikki Linnakangas
15b7022baa Allow 'tenant_create' with a tenant token.
Perform permission check with the given tenant_id, when creating a new
tenant. Seems more consistent with all the other operations,
tenant_create was the only operation you couldn't perform on a tenant
with a tenant token.
2023-05-24 00:56:06 +03:00
Heikki Linnakangas
56cb319120 Make tenant ID mandatory in tenant_create API call.
We used to generate it, if the caller didn't specify it. That's bad
practice, however, because network is never fully reliable, so it's
possible we create a new tenant but the caller doesn't know about it,
and because it doesn't know the tenant ID, it has no way of retrying
or checking if it succeeded. To discourage that, make it mandatory.
The web control plane has not relied on the auto-generation for a long
time.
2023-05-24 00:47:35 +03:00
2 changed files with 10 additions and 5 deletions

View File

@@ -819,7 +819,7 @@ async fn tenant_create_handler(
) -> Result<Response<Body>, ApiError> {
let request_data: TenantCreateRequest = json_request(&mut request).await?;
let target_tenant_id = request_data.new_tenant_id;
check_permission(&request, None)?;
check_permission(&request, Some(target_tenant_id))?;
let _timer = STORAGE_TIME_GLOBAL
.get_metric_with_label_values(&[StorageTimeOperation::CreateTenant.into()])

View File

@@ -54,12 +54,17 @@ def test_pageserver_auth(neon_env_builder: NeonEnvBuilder):
# create tenant using management token
pageserver_http_client.tenant_create(TenantId.generate())
# fail to create tenant using tenant token
# fail to create tenant with another tenant's token
new_tenant_id = TenantId.generate()
with pytest.raises(
PageserverApiException,
match="Forbidden: Attempt to access management api with tenant scope. Permission denied",
PageserverApiException, match="Forbidden: Tenant id mismatch. Permission denied"
):
tenant_http_client.tenant_create(TenantId.generate())
tenant_http_client.tenant_create(new_tenant_id)
# succeed with the tenant's token
new_tenant_token = env.auth_keys.generate_tenant_token(new_tenant_id)
new_tenant_http_client = env.pageserver.http_client(new_tenant_token)
new_tenant_http_client.tenant_create(new_tenant_id)
def test_compute_auth_to_pageserver(neon_env_builder: NeonEnvBuilder):