本文整理汇总了Python中security_monkey.views.__check_auth__函数的典型用法代码示例。如果您正苦于以下问题:Python __check_auth__函数的具体用法?Python __check_auth__怎么用?Python __check_auth__使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了__check_auth__函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: post
def post(self):
"""
.. http:post:: /api/1/whitelistcidrs
Create a new CIDR whitelist entry.
**Example Request**:
.. sourcecode:: http
POST /api/1/whitelistcidrs HTTP/1.1
Host: example.com
Accept: application/json
{
"name": "Corp",
"notes": "Corporate Network",
"cidr": "1.2.3.4/22"
}
**Example Response**:
.. sourcecode:: http
HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
{
"id": 123,
"name": "Corp",
"notes": "Corporate Network",
"cidr": "1.2.3.4/22"
}
:statuscode 201: created
:statuscode 401: Authentication Error. Please Login.
"""
auth, retval = __check_auth__(self.auth_dict)
if auth:
return retval
self.reqparse.add_argument('name', required=True, type=unicode, help='Must provide account name', location='json')
self.reqparse.add_argument('cidr', required=True, type=unicode, help='Network CIDR required.', location='json')
self.reqparse.add_argument('notes', required=False, type=unicode, help='Add context.', location='json')
args = self.reqparse.parse_args()
name = args['name']
cidr = args.get('cidr', True)
notes = args.get('notes', None)
whitelist_entry = NetworkWhitelistEntry()
whitelist_entry.name = name
whitelist_entry.cidr = cidr
if notes:
whitelist_entry.notes = notes
db.session.add(whitelist_entry)
db.session.commit()
db.session.refresh(whitelist_entry)
whitelistentry_marshaled = marshal(whitelist_entry.__dict__, WHITELIST_FIELDS)
whitelistentry_marshaled['auth'] = self.auth_dict
return whitelistentry_marshaled, 201
开发者ID:darrow,项目名称:security_monkey,代码行数:64,代码来源:whitelist.py
示例17: put
def put(self, item_id):
"""
.. http:get:: /api/1/whitelistcidrs/<int:id>
Update the whitelist entry with the given ID.
**Example Request**:
.. sourcecode:: http
PUT /api/1/whitelistcidrs/123 HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
{
"id": 123,
"name": "Corp",
"notes": "Corporate Network - New",
"cidr": "2.2.0.0/16"
}
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
"id": 123,
"name": "Corp",
"notes": "Corporate Network - New",
"cidr": "2.2.0.0/16",
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
self.reqparse.add_argument('name', required=True, type=unicode, help='Must provide account name', location='json')
self.reqparse.add_argument('cidr', required=True, type=unicode, help='Network CIDR required.', location='json')
self.reqparse.add_argument('notes', required=False, type=unicode, help='Add context.', location='json')
args = self.reqparse.parse_args()
name = args['name']
cidr = args.get('cidr', True)
notes = args.get('notes', None)
result = NetworkWhitelistEntry.query.filter(NetworkWhitelistEntry.id == item_id).first()
if not result:
return {"status": "Whitelist entry with the given ID not found."}, 404
result.name = name
result.cidr = cidr
result.notes = notes
db.session.add(result)
db.session.commit()
db.session.refresh(result)
whitelistentry_marshaled = marshal(result.__dict__, WHITELIST_FIELDS)
whitelistentry_marshaled['auth'] = self.auth_dict
return whitelistentry_marshaled, 200
开发者ID:darrow,项目名称:security_monkey,代码行数:74,代码来源:whitelist.py
示例18: post
def post(self):
"""
.. http:post:: /api/1/account/
Create a new account.
**Example Request**:
.. sourcecode:: http
POST /api/1/account/ HTTP/1.1
Host: example.com
Accept: application/json
{
'name': 'new_account'
's3_name': 'new_account',
'number': '0123456789',
'notes': 'this account is for ...',
'active': true,
'third_party': false
}
**Example Response**:
.. sourcecode:: http
HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
{
'name': 'new_account'
's3_name': 'new_account',
'number': '0123456789',
'notes': 'this account is for ...',
'active': true,
'third_party': false
}
:statuscode 201: created
:statuscode 401: Authentication Error. Please Login.
"""
auth, retval = __check_auth__(self.auth_dict)
if auth:
return retval
self.reqparse.add_argument('name', required=True, type=unicode, help='Must provide account name', location='json')
self.reqparse.add_argument('s3_name', required=False, type=unicode, help='Will use name if s3_name not provided.', location='json')
self.reqparse.add_argument('number', required=False, type=unicode, help='Add the account number if available.', location='json')
self.reqparse.add_argument('notes', required=False, type=unicode, help='Add context.', location='json')
self.reqparse.add_argument('active', required=False, type=bool, help='Determines whether this account should be interrogated by security monkey.', location='json')
self.reqparse.add_argument('third_party', required=False, type=bool, help='Determines whether this account is a known friendly third party account.', location='json')
args = self.reqparse.parse_args()
name = args['name']
s3_name = args.get('s3_name', name)
number = args.get('number', None)
notes = args.get('notes', None)
active = args.get('active', True)
third_party = args.get('third_party', False)
account = Account()
account.name = name
account.s3_name = s3_name
account.number = number
account.notes = notes
account.active = active
account.third_party = third_party
db.session.add(account)
db.session.commit()
updated_account = Account.query.filter(Account.id == account.id).first()
marshaled_account = marshal(updated_account.__dict__, ACCOUNT_FIELDS)
marshaled_account['auth'] = self.auth_dict
return marshaled_account, 201
开发者ID:agilemobiledev,项目名称:security_monkey,代码行数:76,代码来源:account.py
示例19: put
def put(self, account_id):
"""
.. http:put:: /api/1/account/1
Edit an existing account.
**Example Request**:
.. sourcecode:: http
PUT /api/1/account/1 HTTP/1.1
Host: example.com
Accept: application/json
{
'name': 'edited_account'
's3_name': 'edited_account',
'number': '0123456789',
'notes': 'this account is for ...',
'role_name': 'CustomRole',
'active': true,
'third_party': false
}
**Example Response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json
{
'name': 'edited_account'
's3_name': 'edited_account',
'number': '0123456789',
'notes': 'this account is for ...',
'role_name': 'CustomRole',
'active': true,
'third_party': false
}
:statuscode 200: no error
:statuscode 401: Authentication Error. Please Login.
"""
auth, retval = __check_auth__(self.auth_dict)
if auth:
return retval
self.reqparse.add_argument('name', required=False, type=unicode, help='Must provide account name', location='json')
self.reqparse.add_argument('s3_name', required=False, type=unicode, help='Will use name if s3_name not provided.', location='json')
self.reqparse.add_argument('number', required=False, type=unicode, help='Add the account number if available.', location='json')
self.reqparse.add_argument('notes', required=False, type=unicode, help='Add context.', location='json')
self.reqparse.add_argument('role_name', required=False, type=unicode, help='Custom role name.', location='json')
self.reqparse.add_argument('active', required=False, type=bool, help='Determines whether this account should be interrogated by security monkey.', location='json')
self.reqparse.add_argument('third_party', required=False, type=bool, help='Determines whether this account is a known friendly third party account.', location='json')
args = self.reqparse.parse_args()
account = Account.query.filter(Account.id == account_id).first()
if not account:
return {'status': 'error. Account ID not found.'}, 404
account.name = args['name']
account.s3_name = args['s3_name']
account.number = args['number']
account.notes = args['notes']
account.role_name = args['role_name']
account.active = args['active']
account.third_party = args['third_party']
db.session.add(account)
db.session.commit()
db.session.refresh(account)
marshaled_account = marshal(account.__dict__, ACCOUNT_FIELDS)
marshaled_account['auth'] = self.auth_dict
return marshaled_account, 200
开发者ID:darrow,项目名称:security_monkey,代码行数:79,代码来源:account.py
示例20: post
def post(self, audit_id):
"""
.. http:post:: /api/1/issues/1234/justification
Justify an audit issue on a specific item.
**Example Request**:
.. sourcecode:: http
POST /api/1/issues/1234/justification HTTP/1.1
Host: example.com
Accept: application/json
{
'justification': 'I promise not to abuse this.'
}
**Example Response**:
.. sourcecode:: http
HTTP/1.1 201 OK
Vary: Accept
Content-Type: application/json
{
"result": {
"justification": "I promise not to abuse this.",
"issue": "Example Issue",
"notes": "Example Notes",
"score": 0,
"item_id": 11890,
"justified_user": "[email protected]",
"justified": true,
"justified_date": "2014-06-19 21:45:58.779168",
"id": 1234
},
"auth": {
"authenticated": true,
"user": "[email protected]"
}
}
:statuscode 201: no error
:statuscode 401: Authentication Error. Please Login.
"""
auth, retval = __check_auth__(self.auth_dict)
if auth:
return retval
self.reqparse.add_argument('justification', required=False, type=str, help='Must provide justification', location='json')
args = self.reqparse.parse_args()
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 = current_user.id
item.justified = True
item.justified_date = datetime.datetime.utcnow()
item.justification = args['justification']
db.session.add(item)
db.session.commit()
db.session.refresh(item)
retdict = {'auth': self.auth_dict}
if item.user:
retdict['result'] = dict(
marshal(item.__dict__, AUDIT_FIELDS).items() +
{"justified_user": item.user.email}.items())
else:
retdict['result'] = dict(
marshal(item.__dict__, AUDIT_FIELDS).items() +
{"justified_user": None}.items())
return retdict, 200
开发者ID:darrow,项目名称:security_monkey,代码行数:79,代码来源:item_issue_justification.py
注:本文中的security_monkey.views.__check_auth__函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论