Skip to content

Commit

Permalink
Merge pull request #3397 from ingef/fix/initial-user-not-mandatory
Browse files Browse the repository at this point in the history
fixes validation of initial users/roles, adds default for overview scope
  • Loading branch information
thoniTUB authored Apr 18, 2024
2 parents 6fd0a48 + d0f3397 commit 3f8c266
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package com.bakdata.conquery.models.config.auth;

import java.util.Collections;
import java.util.List;
import java.util.Set;

import com.bakdata.conquery.apiv1.auth.ProtoRole;
import com.bakdata.conquery.apiv1.auth.ProtoUser;
import com.bakdata.conquery.io.cps.CPSType;
import com.bakdata.conquery.models.auth.permissions.AdminPermission;
import com.bakdata.conquery.models.auth.permissions.DatasetPermission;
import com.bakdata.conquery.models.auth.permissions.SuperPermission;
import io.dropwizard.validation.ValidationMethod;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.Getter;
import lombok.Data;

@CPSType(base = AuthorizationConfig.class, id = "DEFAULT")
@Getter
@Data
public class DefaultAuthorizationConfig implements AuthorizationConfig {

@Valid
Expand All @@ -21,10 +25,14 @@ public class DefaultAuthorizationConfig implements AuthorizationConfig {
.permissions(Set.of(AdminPermission.DOMAIN))
.build());

@NotEmpty
@Valid
private List<ProtoUser> initialUsers;
private List<ProtoUser> initialUsers = Collections.emptyList();

@NotEmpty
private List<String> overviewScope;
private List<String> overviewScope = List.of(DatasetPermission.DOMAIN, AdminPermission.DOMAIN, SuperPermission.DOMAIN);

@ValidationMethod(message = "No initial entities defined. Access will not be possible")
public boolean isInitialAccessPossible() {
return !(initialRoles.isEmpty() && initialUsers.isEmpty());
}
}

0 comments on commit 3f8c266

Please sign in to comment.