You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by GitBox <gi...@apache.org> on 2021/03/24 09:22:04 UTC

[GitHub] [syncope] mmoayyed opened a new pull request #251: Support delegation/impersonation for WA

mmoayyed opened a new pull request #251:
URL: https://github.com/apache/syncope/pull/251


   Core API& components design. To be refined.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [syncope] ilgrosso commented on pull request #251: Support delegation/impersonation for WA

Posted by GitBox <gi...@apache.org>.
ilgrosso commented on pull request #251:
URL: https://github.com/apache/syncope/pull/251#issuecomment-809320091


   @mmoayyed I think a sub-task of SYNCOPE-1545 would be needed for this implementation, also to be used in this PR's title and final commit message.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [syncope] ilgrosso commented on a change in pull request #251: SYNCOPE-1625 - Support delegation/impersonation for WA

Posted by GitBox <gi...@apache.org>.
ilgrosso commented on a change in pull request #251:
URL: https://github.com/apache/syncope/pull/251#discussion_r603822506



##########
File path: common/am/lib/src/main/java/org/apache/syncope/common/lib/wa/ImpersonationAccount.java
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.lib.wa;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.syncope.common.lib.BaseBean;
+
+import javax.ws.rs.PathParam;
+
+public class ImpersonationAccount implements BaseBean {
+
+    private static final long serialVersionUID = 2285073386484048953L;
+
+    private String id;

Review comment:
       What is the purpose of having both `id` and `key` here? If `id` is provided and must be unique, just rename it as `key` and drop the existing, auto-generated, `key`.

##########
File path: common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/wa/ImpersonationService.java
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.common.rest.api.service.wa;
+
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityRequirements;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.JAXRSService;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.util.List;
+
+@Tag(name = "WA")
+@SecurityRequirements({
+    @SecurityRequirement(name = "BasicAuthentication"),
+    @SecurityRequirement(name = "Bearer")})
+@Path("wa/impersonation")
+public interface ImpersonationService extends JAXRSService {
+    @GET
+    @Path("accounts/{owner}")
+    @Consumes({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    @Produces({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    List<ImpersonationAccount> findByOwner(@NotNull @PathParam("owner") String owner);
+
+    @GET
+    @Path("authz/{owner}")
+    @Consumes({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    @Produces({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    ImpersonationAccount find(@NotNull @PathParam("owner") String owner,
+                              @NotNull @QueryParam("id") String id);
+
+    @POST
+    @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    Response create(@NotNull ImpersonationAccount account);

Review comment:
       No way to update or delete and `ImpersonationAccount`: is this intended?

##########
File path: core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/wa/ImpersonationServiceImpl.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.core.rest.cxf.service.wa;
+
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.ImpersonationService;
+import org.apache.syncope.core.logic.wa.ImpersonationLogic;
+import org.apache.syncope.core.rest.cxf.service.AbstractServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.ws.rs.core.Response;
+
+import java.net.URI;
+import java.util.List;
+
+@Service
+public class ImpersonationServiceImpl extends AbstractServiceImpl implements ImpersonationService {
+
+    @Autowired
+    private ImpersonationLogic logic;
+
+    @Override
+    public List<ImpersonationAccount> findByOwner(final String owner) {
+        return logic.findByOwner(owner);
+    }
+
+    @Override
+    public ImpersonationAccount find(final String owner,
+                         final String id) {
+        return logic.find(owner, id);
+    }
+
+    @Override
+    public Response create(final ImpersonationAccount account) {
+        String key = logic.create(account);
+        URI location = uriInfo.getAbsolutePathBuilder().path(key).build();
+        return Response.created(location).
+            header(RESTHeaders.RESOURCE_KEY, key).

Review comment:
       Returning such header value implies there is a way to read the created object by the returned URI

##########
File path: core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/ImpersonationLogic.java
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.core.logic.wa;
+
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.types.AMEntitlement;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
+import org.apache.syncope.common.lib.types.IdRepoEntitlement;
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.core.logic.AbstractAuthProfileLogic;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.auth.AuthProfile;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class ImpersonationLogic extends AbstractAuthProfileLogic {
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_READ_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public List<ImpersonationAccount> findByOwner(final String owner) {
+        return authProfileDAO.findByOwner(owner).map(AuthProfile::getImpersonationAccounts).orElse(List.of());
+    }
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_READ_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public ImpersonationAccount find(final String owner, final String id) {
+        return authProfileDAO.findByOwner(owner)
+            .map(AuthProfile::getImpersonationAccounts)
+            .stream()
+            .flatMap(List::stream)
+            .filter(acct -> acct.getId().equalsIgnoreCase(id))
+            .findFirst()
+            .orElseThrow(() -> {
+                SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);

Review comment:
       [`ClientExceptionType.DelegatedAdminstration`](https://github.com/apache/syncope/blob/master/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java#L78) can be used here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [syncope] mmoayyed commented on pull request #251: Support delegation/impersonation for WA

Posted by GitBox <gi...@apache.org>.
mmoayyed commented on pull request #251:
URL: https://github.com/apache/syncope/pull/251#issuecomment-809470168


   Thanks much for the review! I'll take care of the sub-task and other changes. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [syncope] mmoayyed merged pull request #251: SYNCOPE-1625 - Support delegation/impersonation for WA

Posted by GitBox <gi...@apache.org>.
mmoayyed merged pull request #251:
URL: https://github.com/apache/syncope/pull/251


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [syncope] mmoayyed commented on a change in pull request #251: SYNCOPE-1625 - Support delegation/impersonation for WA

Posted by GitBox <gi...@apache.org>.
mmoayyed commented on a change in pull request #251:
URL: https://github.com/apache/syncope/pull/251#discussion_r603867863



##########
File path: common/am/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/wa/ImpersonationService.java
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.common.rest.api.service.wa;
+
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityRequirements;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.JAXRSService;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.util.List;
+
+@Tag(name = "WA")
+@SecurityRequirements({
+    @SecurityRequirement(name = "BasicAuthentication"),
+    @SecurityRequirement(name = "Bearer")})
+@Path("wa/impersonation")
+public interface ImpersonationService extends JAXRSService {
+    @GET
+    @Path("accounts/{owner}")
+    @Consumes({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    @Produces({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    List<ImpersonationAccount> findByOwner(@NotNull @PathParam("owner") String owner);
+
+    @GET
+    @Path("authz/{owner}")
+    @Consumes({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    @Produces({MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML})
+    ImpersonationAccount find(@NotNull @PathParam("owner") String owner,
+                              @NotNull @QueryParam("id") String id);
+
+    @POST
+    @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    Response create(@NotNull ImpersonationAccount account);

Review comment:
       I did add both (WA may only use READ). For now, the update operation is more or less a no-op because there is nothing to update. However, I imagine that in the future, the impersonation-account would be tagged and enriched with additional information which would allow the update operation to be more practically meaningful.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [syncope] ilgrosso commented on a change in pull request #251: Support delegation/impersonation for WA

Posted by GitBox <gi...@apache.org>.
ilgrosso commented on a change in pull request #251:
URL: https://github.com/apache/syncope/pull/251#discussion_r603231512



##########
File path: core/am/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/wa/ImpersonationServiceImpl.java
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.core.rest.cxf.service.wa;
+
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.wa.ImpersonationService;
+import org.apache.syncope.core.logic.wa.ImpersonationLogic;
+import org.apache.syncope.core.rest.cxf.service.AbstractServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.ws.rs.core.Response;
+
+import java.net.URI;
+import java.util.List;
+
+@Service
+public class ImpersonationServiceImpl extends AbstractServiceImpl implements ImpersonationService {
+
+    @Autowired
+    private ImpersonationLogic logic;
+
+    @Override
+    public List<ImpersonationAccount> findByOwner(final String owner) {
+        return logic.findByOwner(owner);
+    }
+
+    @Override
+    public Response find(final String owner,
+                         final String id,
+                         final String application) {
+        return logic.find(owner, id, application)

Review comment:
       this kind of security checks should be delegated to the logic layer, by Spring Security annotations if possible, otherwise by raising the appropriate client exception

##########
File path: core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/ImpersonationLogic.java
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.core.logic.wa;
+
+import org.apache.syncope.common.lib.types.AMEntitlement;
+import org.apache.syncope.common.lib.types.IdRepoEntitlement;
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.core.logic.AbstractAuthProfileLogic;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.auth.AuthProfile;
+import org.apache.syncope.core.spring.security.SecureRandomUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class ImpersonationLogic extends AbstractAuthProfileLogic {
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_READ_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public List<ImpersonationAccount> findByOwner(final String owner) {
+        return authProfileDAO.findByOwner(owner).map(AuthProfile::getImpersonationAccounts).orElse(List.of());
+    }
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_READ_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public Boolean find(final String owner,
+                        final String id,
+                        final String application) {

Review comment:
       CodeQL reports that `application` is unused here.

##########
File path: core/am/logic/src/main/java/org/apache/syncope/core/logic/wa/ImpersonationLogic.java
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.syncope.core.logic.wa;
+
+import org.apache.syncope.common.lib.types.AMEntitlement;
+import org.apache.syncope.common.lib.types.IdRepoEntitlement;
+import org.apache.syncope.common.lib.wa.ImpersonationAccount;
+import org.apache.syncope.core.logic.AbstractAuthProfileLogic;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.auth.AuthProfile;
+import org.apache.syncope.core.spring.security.SecureRandomUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class ImpersonationLogic extends AbstractAuthProfileLogic {
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_READ_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public List<ImpersonationAccount> findByOwner(final String owner) {
+        return authProfileDAO.findByOwner(owner).map(AuthProfile::getImpersonationAccounts).orElse(List.of());
+    }
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_READ_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public Boolean find(final String owner,
+                        final String id,
+                        final String application) {
+        return authProfileDAO.findByOwner(owner)
+            .map(profile -> profile.getImpersonationAccounts()
+                .stream()
+                .anyMatch(acct -> acct.getId().equalsIgnoreCase(id)))
+            .stream().findFirst().orElse(Boolean.FALSE);
+    }
+
+    @PreAuthorize("hasRole('" + AMEntitlement.IMPERSONATION_CREATE_ACCOUNT + "')"
+        + "or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
+    public String create(final ImpersonationAccount account) {
+        if (account.getKey() == null) {
+            account.setKey(SecureRandomUtils.generateRandomUUID().toString());

Review comment:
       This is not needed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org