Android 限制对google应用程序引擎端点方法的访问

Android 限制对google应用程序引擎端点方法的访问,android,google-app-engine,google-cloud-datastore,google-cloud-endpoints,Android,Google App Engine,Google Cloud Datastore,Google Cloud Endpoints,我有一个关于谷歌应用程序引擎端点安全性的问题。我上传的数据存储中有一个数据,这些数据只能从Android应用程序读取 我检索的所有数据如下所示: Personendpoint.Builder endpointBuilder = new Personendpoint.Builder( AndroidHttp.newCompatibleTransport(), new JacksonFactory(), null); endpointBuilder =

我有一个关于谷歌应用程序引擎端点安全性的问题。我上传的数据存储中有一个数据,这些数据只能从Android应用程序读取

我检索的所有数据如下所示:

Personendpoint.Builder endpointBuilder = new Personendpoint.Builder(
                AndroidHttp.newCompatibleTransport(), new JacksonFactory(), null);
        endpointBuilder = CloudEndpointUtils.updateBuilder(endpointBuilder);
        CollectionResponsePerson result;

        Personendpoint endpoint = endpointBuilder.build();


        try {
            result = endpoint.listPerson().execute();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            result = null;
        }
在我的个人观点中,我有以下几点:

@Api(name = "personendpoint", namespace = @ApiNamespace(ownerDomain = "test.com", ownerName = "test.com", packagePath = "personmanagement"))
public class PersonEndpoint {

    /**
     * This method lists all the entities inserted in datastore.
     * It uses HTTP GET method and paging support.
     *
     * @return A CollectionResponse class containing the list of all entities
     * persisted and a cursor to the next page.
     */
    @SuppressWarnings({ "unchecked", "unused" })
    @ApiMethod(name = "listPerson")
    public CollectionResponse<Person> listPerson(@Nullable @Named("cursor") String cursorString,
            @Nullable @Named("limit") Integer limit) 
    {
     ...
    }
@Api(name=“personedpoint”,namespace=@ApiNamespace(ownerDomain=“test.com”,ownerName=“test.com”,packagePath=“personmanagement”))
公共类个人点{
/**
*此方法列出数据存储中插入的所有实体。
*它使用HTTP GET方法和分页支持。
*
*@返回包含所有实体列表的CollectionResponse类
*持久化,并将光标移到下一页。
*/
@SuppressWarnings({“未选中”、“未使用”})
@ApiMethod(name=“listPerson”)
public CollectionResponse listPerson(@Nullable@Named(“游标”)字符串cursorString,
@可为空@命名(“限制”)整数限制)
{
...
}
与此类似,还有一些方法
insertPerson
removePerson
,在这种情况下非常危险。攻击者可以轻松触发这些方法并从我的数据存储中删除数据。如何保护这些方法


我只允许用户从数据存储中获取数据。谢谢。

您可以轻松地在web.xml中实施安全约束

<security-constraint>
    <web-resource-collection>
        <web-resource-name>personmanagement</web-resource-name>
        <url-pattern>/personmanagement/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
</security-constraint>

人事管理
/人事管理/*

我建议您保护您的端点。除此之外,您还有责任检查经过身份验证的用户的角色和权限,并过滤他将作为任何其他web应用程序管理的数据