当前位置: 首页>>代码示例>>Python>>正文


Python views.__check_auth__函数代码示例

本文整理汇总了Python中security_monkey.views.__check_auth__函数的典型用法代码示例。如果您正苦于以下问题:Python __check_auth__函数的具体用法?Python __check_auth__怎么用?Python __check_auth__使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了__check_auth__函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

    def post(self, revision_id):
        """
            .. http:post:: /api/1/revisions/<int:revision_id>/comments

            Create a new Revision Comment.

            **Example Request**:

            .. sourcecode:: http

                POST /api/1/revisions/1141/comments HTTP/1.1
                Host: example.com
                Accept: application/json

                {
                    "text": "This is a Revision Comment."
                }


            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 201 OK
                Vary: Accept
                Content-Type: application/json

                {
                    'id': 22,
                    'revision_id': 1141,
                    "date_created": "2013-10-04 22:01:47",
                    'text': 'This is a Revision Comment.'
                }

            :statuscode 201: Revision Comment Created
            :statuscode 401: Authentication Error. Please Login.
        """

        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        self.reqparse.add_argument('text', required=False, type=unicode, help='Must provide comment', location='json')
        args = self.reqparse.parse_args()

        irc = ItemRevisionComment()
        irc.user_id = current_user.id
        irc.revision_id = revision_id
        irc.text = args['text']
        irc.date_created = datetime.datetime.utcnow()
        db.session.add(irc)
        db.session.commit()

        irc_committed = ItemRevisionComment.query.filter(ItemRevisionComment.id == irc.id).first()
        revision_marshaled = marshal(irc_committed.__dict__, REVISION_COMMENT_FIELDS)
        revision_marshaled = dict(
            revision_marshaled.items() +
            {'user': irc_committed.user.email}.items()
        )
        return revision_marshaled, 200
开发者ID:MahidharNaga,项目名称:security_monkey,代码行数:60,代码来源:revision_comment.py

示例2: get

    def get(self, audit_id):
        """
            .. http:get:: /api/1/issue/1234

            Get a specific issue

            **Example Request**:

            .. sourcecode:: http

                GET /api/1/issue/1234 HTTP/1.1
                Host: example.com
                Accept: application/json

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    justification: null,
                    name: "example_name",
                    issue: "Example Audit Issue",
                    notes: "Example Notes on Audit Issue",
                    auth: {
                        authenticated: true,
                        user: "[email protected]"
                    },
                    score: 0,
                    item_id: 704,
                    region: "us-east-1",
                    justified: false,
                    justified_date: null,
                    id: 704
                }

            :statuscode 200: no error
            :statuscode 401: Authentication Error. Please login.
        """

        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        query = ItemAudit.query.join("item").filter(ItemAudit.id == audit_id)
        result = query.first()

        issue_marshaled = marshal(result, AUDIT_FIELDS)
        item_marshaled = marshal(result.item, ITEM_FIELDS)
        issue_marshaled = dict(
            issue_marshaled.items() +
            item_marshaled.items() +
            {'auth': self.auth_dict}.items()
        )
        return issue_marshaled, 200
开发者ID:MahidharNaga,项目名称:security_monkey,代码行数:58,代码来源:item_issue.py

示例3: get

    def get(self, revision_id, comment_id):
        """
            .. http:get:: /api/1/revisions/<int:revision_id>/comments/<int:comment_id>

            Get a specific Revision Comment

            **Example Request**:

            .. sourcecode:: http

                GET /api/1/revisions/1141/comments/22 HTTP/1.1
                Host: example.com
                Accept: application/json


            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    'id': 22,
                    'revision_id': 1141,
                    "date_created": "2013-10-04 22:01:47",
                    'text': 'This is a Revision Comment.'
                }

            :statuscode 200: no error
            :statuscode 404: Revision Comment with given ID not found.
            :statuscode 401: Authentication Error. Please Login.
        """

        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        query = ItemRevisionComment.query.filter(ItemRevisionComment.id == comment_id)
        query = query.filter(ItemRevisionComment.revision_id == revision_id)
        irc = query.first()

        if irc is None:
            return {"status": "Revision Comment Not Found"}, 404

        revision_marshaled = marshal(irc.__dict__, REVISION_COMMENT_FIELDS)
        revision_marshaled = dict(
            revision_marshaled.items() +
            {'user': irc.user.email}.items()
        )

        return revision_marshaled, 200
开发者ID:AlexCline,项目名称:security_monkey,代码行数:53,代码来源:revision_comment.py

示例4: get

    def get(self, item_id, comment_id):
        """
            .. http:get:: /api/1/items/<int:item_id>/comment/<int:comment_id>

            Retrieves an item comment.

            **Example Request**:

            .. sourcecode:: http

                GET /api/1/items/1234/comment/7718 HTTP/1.1
                Host: example.com
                Accept: application/json

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    'id': 7719,
                    'date_created': "2013-10-04 22:01:47",
                    'text': 'This is an Item Comment.',
                    'item_id': 1111
                }

            :statuscode 200: Success
            :statuscode 404: Comment with given ID not found.
            :statuscode 401: Authentication Error. Please Login.
        """

        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        query = ItemComment.query.filter(ItemComment.id == comment_id)
        query = query.filter(ItemComment.item_id == item_id)
        ic = query.first()

        if ic is None:
            return {"status": "Item Comment Not Found"}, 404

        comment_marshaled = marshal(ic.__dict__, ITEM_COMMENT_FIELDS)
        comment_marshaled = dict(
            comment_marshaled.items() +
            {'user': ic.user.email}.items()
        )

        return comment_marshaled, 200
开发者ID:Yelp,项目名称:security_monkey,代码行数:52,代码来源:item_comment.py

示例5: delete

    def delete(self, audit_id):
        """
            .. http:delete:: /api/1/issues/1234/justification

            Remove a justification on an audit issue on a specific item.

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/issues/1234/justification HTTP/1.1
                Host: example.com
                Accept: application/json


            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 202 OK
                Vary: Accept
                Content-Type: application/json

                {
                    "status": "deleted"
                }


            :statuscode 202: Accepted
            :statuscode 401: Authentication Error. Please Login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        if not __check_admin__():
            return {"Error": "You must be an admin to delete justifications"}, 403

        item = ItemAudit.query.filter(ItemAudit.id == audit_id).first()
        if not item:
            return {"Error": "Item with audit_id {} not found".format(audit_id)}, 404

        item.justified_user_id = None
        item.justified = False
        item.justified_date = None
        item.justification = None

        db.session.add(item)
        db.session.commit()

        return {"status": "deleted"}, 202
开发者ID:Yelp,项目名称:security_monkey,代码行数:51,代码来源:item_issue_justification.py

示例6: get

    def get(self, item_id):
        """
            .. http:get:: /api/1/ignorelistentries/<int:id>

            Get the ignorelist entry with the given ID.

            **Example Request**:

            .. sourcecode:: http

                GET /api/1/ignorelistentries/123 HTTP/1.1
                Host: example.com
                Accept: application/json, text/javascript

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    "id": 123,
                    "prefix": "noisy_",
                    "notes": "Security Monkey shouldn't track noisy_* objects",
                    "technology": "securitygroup",
                    auth: {
                        authenticated: true,
                        user: "[email protected]"
                    }
                }

            :statuscode 200: no error
            :statuscode 404: item with given ID not found
            :statuscode 401: Authentication failure. Please login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        result = IgnoreListEntry.query.filter(IgnoreListEntry.id == item_id).first()

        if not result:
            return {"status": "Ignorelist entry with the given ID not found."}, 404

        ignorelistentry_marshaled = marshal(result.__dict__, IGNORELIST_FIELDS)
        ignorelistentry_marshaled['technology'] = result.technology.name
        ignorelistentry_marshaled['auth'] = self.auth_dict

        return ignorelistentry_marshaled, 200
开发者ID:MahidharNaga,项目名称:security_monkey,代码行数:51,代码来源:ignore_list.py

示例7: get

    def get(self, account_id):
        """
            .. http:get:: /api/1/account/<int:id>

            Get a list of Accounts matching the given criteria

            **Example Request**:

            .. sourcecode:: http

                GET /api/1/account/1 HTTP/1.1
                Host: example.com
                Accept: application/json, text/javascript

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    third_party: false,
                    name: "example_name",
                    notes: null,
                    role_name: null,
                    number: "111111111111",
                    active: true,
                    id: 1,
                    s3_name: "example_name",
                    auth: {
                        authenticated: true,
                        user: "[email protected]"
                    }
                }

            :statuscode 200: no error
            :statuscode 401: Authentication failure. Please login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        result = Account.query.filter(Account.id == account_id).first()

        account_marshaled = marshal(result.__dict__, ACCOUNT_FIELDS)
        account_marshaled['auth'] = self.auth_dict

        return account_marshaled, 200
开发者ID:darrow,项目名称:security_monkey,代码行数:50,代码来源:account.py

示例8: get

    def get(self, item_id):
        """
            .. http:get:: /api/1/whitelistcidrs/<int:id>

            Get the whitelist entry with the given ID.

            **Example Request**:

            .. sourcecode:: http

                GET /api/1/whitelistcidrs/123 HTTP/1.1
                Host: example.com
                Accept: application/json, text/javascript

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    "id": 123,
                    "name": "Corp",
                    "notes": "Corporate Network",
                    "cidr": "1.2.3.4/22",
                    auth: {
                        authenticated: true,
                        user: "[email protected]"
                    }
                }

            :statuscode 200: no error
            :statuscode 404: item with given ID not found
            :statuscode 401: Authentication failure. Please login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        result = NetworkWhitelistEntry.query.filter(NetworkWhitelistEntry.id == item_id).first()

        if not result:
            return {"status": "Whitelist entry with the given ID not found."}, 404

        whitelistentry_marshaled = marshal(result.__dict__, WHITELIST_FIELDS)
        whitelistentry_marshaled['auth'] = self.auth_dict

        return whitelistentry_marshaled, 200
开发者ID:darrow,项目名称:security_monkey,代码行数:50,代码来源:whitelist.py

示例9: delete

    def delete(self, account_id):
        """
            .. http:delete:: /api/1/account/1

            Delete an account.

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/account/1 HTTP/1.1
                Host: example.com
                Accept: application/json

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 202 Accepted
                Vary: Accept
                Content-Type: application/json

                {
                    'status': 'deleted'
                }

            :statuscode 202: accepted
            :statuscode 401: Authentication Error. Please Login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        if not __check_admin__():
            return {"Error": "You must be an admin to edit accounts"}, 403

        # Need to unsubscribe any users first:
        users = User.query.filter(User.accounts.any(Account.id == account_id)).all()
        for user in users:
            user.accounts = [account for account in user.accounts if not account.id == account_id]
            db.session.add(user)
        db.session.commit()

        account = Account.query.filter(Account.id == account_id).first()

        db.session.delete(account)
        db.session.commit()

        return {'status': 'deleted'}, 202
开发者ID:Yelp,项目名称:security_monkey,代码行数:49,代码来源:account.py

示例10: put

    def put(self, as_id):
        """
            .. http:put:: /api/1/auditorsettings/<int ID>

            Update an AuditorSetting

            **Example Request**:

            .. sourcecode:: http

                PUT /api/1/auditorsettings/1 HTTP/1.1
                Host: example.com
                Accept: application/json, text/javascript

                {
                    account: "aws-account-name",
                    disabled: false,
                    id: 1,
                    issue: "User with password login.",
                    technology: "iamuser"
                }


            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Content-Type: application/json

            :statuscode 200: no error
            :statuscode 401: Authentication failure. Please login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        if not __check_admin__():
            return {"Error": "You must be an admin to edit the auditor settings"}, 403

        self.reqparse.add_argument('disabled', type=bool, required=True, location='json')
        args = self.reqparse.parse_args()
        disabled = args.pop('disabled', None)
        results = AuditorSettings.query.get(as_id)
        results.disabled = disabled
        db.session.add(results)
        db.session.commit()
        return 200
开发者ID:Yelp,项目名称:security_monkey,代码行数:48,代码来源:auditor_settings.py

示例11: delete

    def delete(self, revision_id, comment_id):
        """
            .. http:delete:: /api/1/revisions/<int:revision_id>/comments/<int:comment_id>

            Delete a specific Revision Comment

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/revisions/1141/comments/22 HTTP/1.1
                Host: example.com
                Accept: application/json


            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept
                Content-Type: application/json

                {
                    'status': "deleted"
                }

            :statuscode 202: Comment Deleted
            :statuscode 404: Revision Comment with given ID not found.
            :statuscode 401: Authentication Error. Please Login.
        """

        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        query = ItemRevisionComment.query.filter(ItemRevisionComment.id == comment_id)
        query = query.filter(ItemRevisionComment.revision_id == revision_id)
        irc = query.first()

        if irc is None:
            return {"status": "Revision Comment Not Found"}, 404

        query.delete()
        db.session.commit()

        return {"status": "deleted"}, 202
开发者ID:AlexCline,项目名称:security_monkey,代码行数:47,代码来源:revision_comment.py

示例12: delete

    def delete(self, item_id, comment_id):
        """
            .. http:delete:: /api/1/items/<int:item_id>/comment/<int:comment_id>

            Deletes an item comment.

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/items/1234/comment/7718 HTTP/1.1
                Host: example.com
                Accept: application/json

                {
                }

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 202 OK
                Vary: Accept
                Content-Type: application/json

                {
                    'status': 'deleted'
                }

            :statuscode 202: Deleted
            :statuscode 401: Authentication Error. Please Login.
        """

        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        query = ItemComment.query.filter(ItemComment.id == comment_id)
        query.filter(ItemComment.user_id == current_user.id).delete()
        db.session.commit()

        return {'result': 'success'}, 202
开发者ID:Yelp,项目名称:security_monkey,代码行数:42,代码来源:item_comment.py

示例13: delete

    def delete(self, item_id):
        """
            .. http:delete:: /api/1/ignorelistentries/123

            Delete a ignorelist entry.

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/ignorelistentries/123 HTTP/1.1
                Host: example.com
                Accept: application/json

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 202 Accepted
                Vary: Accept
                Content-Type: application/json

                {
                    'status': 'deleted'
                }

            :statuscode 202: accepted
            :statuscode 401: Authentication Error. Please Login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        if not __check_admin__():
            return {"Error": "You must be an admin to edit the ignore list"}, 403

        IgnoreListEntry.query.filter(IgnoreListEntry.id == item_id).delete()
        db.session.commit()

        return {'status': 'deleted'}, 202
开发者ID:Yelp,项目名称:security_monkey,代码行数:40,代码来源:ignore_list.py

示例14: delete

    def delete(self, item_id):
        """
            .. http:delete:: /api/1/whitelistcidrs/123

            Delete a network whitelist entry.

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/whitelistcidrs/123 HTTP/1.1
                Host: example.com
                Accept: application/json

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 202 Accepted
                Vary: Accept
                Content-Type: application/json

                {
                    'status': 'deleted'
                }

            :statuscode 202: accepted
            :statuscode 401: Authentication Error. Please Login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        NetworkWhitelistEntry.query.filter(NetworkWhitelistEntry.id == item_id).delete()
        db.session.commit()

        return {'status': 'deleted'}, 202
开发者ID:darrow,项目名称:security_monkey,代码行数:37,代码来源:whitelist.py

示例15: delete

    def delete(self, account_id):
        """
            .. http:delete:: /api/1/account/1

            Delete an account.

            **Example Request**:

            .. sourcecode:: http

                DELETE /api/1/account/1 HTTP/1.1
                Host: example.com
                Accept: application/json

            **Example Response**:

            .. sourcecode:: http

                HTTP/1.1 202 Accepted
                Vary: Accept
                Content-Type: application/json

                {
                    'status': 'deleted'
                }

            :statuscode 202: accepted
            :statuscode 401: Authentication Error. Please Login.
        """
        auth, retval = __check_auth__(self.auth_dict)
        if auth:
            return retval

        Account.query.filter(Account.id == account_id).delete()
        db.session.commit()

        return {'status': 'deleted'}, 202
开发者ID:MahidharNaga,项目名称:security_monkey,代码行数:37,代码来源:account.py


注:本文中的security_monkey.views.__check_auth__函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。