auth.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:professional-services 作者: GoogleCloudPlatform 项目源码 文件源码
def is_admin(self, credentials):
        """Check if user has appengine.admin role.

        Calls iam.projects.testIamPermissions with
        appengine.applications.update to determine if the current logged in
        user is an application admin.

        Args:
            credentials: the user's access token.

        Returns:
            True if user is an admin, False otherwise.
        """
        admin_permission = 'appengine.applications.update'
        body = {'permissions': admin_permission}
        http = credentials.authorize(httplib2.Http())
        response = api.CLIENTS.iam.projects().testIamPermissions(
            resource=config.get_project_id(), body=body).execute(http=http)
        return admin_permission in response.get('permissions', [])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号