Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix entity not found in Authorizer init #3177

Merged
merged 1 commit into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.openmetadata.catalog.exception.EntityNotFoundException;
import org.openmetadata.catalog.jdbi3.CollectionDAO;
import org.openmetadata.catalog.jdbi3.RoleRepository;
import org.openmetadata.catalog.jdbi3.TeamRepository;
import org.openmetadata.catalog.jdbi3.UserRepository;
import org.openmetadata.catalog.resources.teams.UserResource;
import org.openmetadata.catalog.security.policyevaluator.PolicyEvaluator;
Expand Down Expand Up @@ -61,10 +62,11 @@ public void init(AuthorizerConfiguration config, Jdbi dbi) throws IOException {
LOG.debug("Admin users: {}", adminUsers);
CollectionDAO collectionDAO = dbi.onDemand(CollectionDAO.class);
this.userRepository = new UserRepository(collectionDAO);
// RoleRepository needs to be instantiated for Entity.DAO_MAP to populated.
// As we create default admin/bots we need to have RoleRepository available in DAO_MAP.
// RoleRepository and TeamRepository needs to be instantiated for Entity.DAO_MAP to populated.
// As we create default admin/bots we need to have RoleRepository and TeamRepository available in DAO_MAP.
// This needs to be handled better in future releases.
RoleRepository roleRepository = new RoleRepository(collectionDAO);
TeamRepository teamRepository = new TeamRepository(collectionDAO);
mayBeAddAdminUsers();
mayBeAddBotUsers();
this.policyEvaluator = PolicyEvaluator.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.openmetadata.catalog.exception.EntityNotFoundException;
import org.openmetadata.catalog.jdbi3.CollectionDAO;
import org.openmetadata.catalog.jdbi3.RoleRepository;
import org.openmetadata.catalog.jdbi3.TeamRepository;
import org.openmetadata.catalog.jdbi3.UserRepository;
import org.openmetadata.catalog.resources.teams.UserResource;
import org.openmetadata.catalog.type.EntityReference;
Expand All @@ -42,10 +43,11 @@ public class NoopAuthorizer implements Authorizer {
public void init(AuthorizerConfiguration config, Jdbi jdbi) {
CollectionDAO collectionDAO = jdbi.onDemand(CollectionDAO.class);
this.userRepository = new UserRepository(collectionDAO);
// RoleRepository needs to be instantiated for Entity.DAO_MAP to populated.
// As we create default admin/bots we need to have RoleRepository available in DAO_MAP.
// RoleRepository and TeamRepository needs to be instantiated for Entity.DAO_MAP to populated.
// As we create default admin/bots we need to have RoleRepository and TeamRepository available in DAO_MAP.
// This needs to be handled better in future releases.
RoleRepository roleRepository = new RoleRepository(collectionDAO);
TeamRepository teamRepository = new TeamRepository(collectionDAO);
addAnonymousUser();
}

Expand Down