Skip to content

Commit

Permalink
Merge pull request #2737 from atlanhq/plt-524-auth-api
Browse files Browse the repository at this point in the history
Plt 524 auth api
  • Loading branch information
sumandas0 authored Jan 9, 2024
2 parents 83ce0e2 + 820a8e1 commit 20b29d9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public KeycloakUserStore(String serviceName) {

public boolean isKeycloakSubjectsStoreUpdated(long cacheLastUpdatedTime) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("getKeycloakSubjectsStoreUpdatedTime");
cacheLastUpdatedTime = -1;
if (cacheLastUpdatedTime == -1) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,6 @@ private static void init(AuthConfig authConfig) {
}
}

public List<UserRepresentation> getAllUsers() throws AtlasBaseException {
int start = 0;
int size = 100;
boolean found = true;

List<UserRepresentation> ret = new ArrayList<>(0);
do {

List<UserRepresentation> userRepresentations = HERACLES.getUsers(start, size, HeraclesUsersRepresentation.USER_PROJECTIONS, null, HeraclesUsersRepresentation.USER_SORT).body().toKeycloakUserRepresentations();
if (userRepresentations != null && !userRepresentations.isEmpty()) {
ret.addAll(userRepresentations);
start += size;
} else {
found = false;
}
} while (found && ret.size() % size == 0);

return ret;
}


public Set<UserRepresentation> getRoleUserMembers(String roleName, int start, int size) throws AtlasBaseException {
String template = "{\"$and\":[{\"roles\":{\"$elemMatch\":[\"{0}\"]}}]}";
String filter = template.replace("{0}", roleName);
return HERACLES.getUsers(start, size, HeraclesUsersRepresentation.USER_PROJECTIONS, filter,HeraclesUsersRepresentation.USER_SORT ).body().toKeycloakUserRepresentations().stream().collect(Collectors.toSet());
}

public List<UserRepresentation> getUsersMappings(int start, int size) throws AtlasBaseException {
String[] columns = {"roles", "groups"};
List<HeraclesUserViewRepresentation> views = HERACLES.getUsersMappings(start, size, HeraclesUserViewRepresentation.sortBy, columns).body();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class HeraclesRestClient extends AbstractAuthClient {
public HeraclesRestClient(final AuthConfig authConfig) {
super(authConfig);
}
public Response<HeraclesUsersRepresentation> getUsers(int offset,int limit, String columns, String filter, String sort) throws AtlasBaseException {
return processResponse(this.retrofitHeraclesClient.getUsers(offset, columns, filter, limit,sort));
}

public Response<List<HeraclesUserViewRepresentation>> getUsersMappings(int offset, int limit, String sort, String[] columns) throws AtlasBaseException {
return processResponse(this.retrofitHeraclesClient.getUsersMapping(offset, limit,sort, columns));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
import java.util.List;

public interface RetrofitHeraclesClient {
@Headers({"Accept: application/json,text/plain", "Cache-Control: no-store", "Cache-Control: no-cache"})
@GET("/users")
Call<HeraclesUsersRepresentation> getUsers(@Query("offset") Integer offset, @Query("columns") String columns,
@Query(value = "filter", encoded = true) String filter, @Query("limit") Integer limit,
@Query("sort") String sort);

@Headers({"Accept: application/json,text/plain", "Cache-Control: no-store", "Cache-Control: no-cache"})
@GET("/users/mappings")
Call<List<HeraclesUserViewRepresentation>> getUsersMapping(@Query("offset") Integer offset, @Query("limit") Integer limit, @Query("sort") String sort,
Expand Down

0 comments on commit 20b29d9

Please sign in to comment.