Skip to content

Commit

Permalink
Fix RBAC to action-alias help and match api.
Browse files Browse the repository at this point in the history
  • Loading branch information
nzlosh committed Nov 18, 2023
1 parent b2dad1e commit 3f46cab
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Fixed
* Bumped `paramiko` to `2.10.5` to fix an issue with SSH Certs - https://github.com/paramiko/paramiko/issues/2017
Contributed by @jk464

* Added RBAC support to action-alias help end point. #6022
Contributed by @nzlosh

Added
~~~~~
* Move `git clone` to `user_home/.st2packs` #5845
Expand Down
9 changes: 6 additions & 3 deletions st2api/st2api/controllers/v1/actionalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def match(self, action_alias_match_api):
Handles requests:
POST /actionalias/match
"""

command = action_alias_match_api.command

try:
Expand All @@ -100,6 +101,7 @@ def match(self, action_alias_match_api):
}

def help(self, filter, pack, limit, offset, **kwargs):

"""
Get available help strings for action aliases.
Expand All @@ -109,15 +111,16 @@ def help(self, filter, pack, limit, offset, **kwargs):
try:
aliases_resp = super(ActionAliasController, self)._get_all(**kwargs)
aliases = [ActionAliasAPI(**alias) for alias in aliases_resp.json]

return generate_helpstring_result(
aliases, filter, pack, int(limit), int(offset)
)
except (TypeError) as e:
except TypeError as exception_type:
LOG.exception(
"Helpstring request contains an invalid data type: %s.",
six.text_type(e),
six.text_type(exception_type),
)
return abort(http_client.BAD_REQUEST, six.text_type(e))
return abort(http_client.BAD_REQUEST, six.text_type(exception_type))

def post(self, action_alias, requester_user):
"""
Expand Down
10 changes: 10 additions & 0 deletions st2common/st2common/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ paths:
description: Object containing the format to be matched.
schema:
$ref: '#/definitions/ActionAliasMatchRequest'
x-parameters:
- name: user
in: context
x-as: requester_user
description: User performing the operation.
responses:
'200':
description: Action alias match pattern
Expand Down Expand Up @@ -840,6 +845,11 @@ paths:
description: Number of actions alias to offset
type: integer
default: 0
x-parameters:
- name: user
in: context
x-as: requester_user
description: User performing the operation.
responses:
'200':
description: Action alias match pattern
Expand Down
10 changes: 10 additions & 0 deletions st2common/st2common/openapi.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,11 @@ paths:
description: Object containing the format to be matched.
schema:
$ref: '#/definitions/ActionAliasMatchRequest'
x-parameters:
- name: user
in: context
x-as: requester_user
description: User performing the operation.
responses:
'200':
description: Action alias match pattern
Expand Down Expand Up @@ -836,6 +841,11 @@ paths:
description: Number of actions alias to offset
type: integer
default: 0
x-parameters:
- name: user
in: context
x-as: requester_user
description: User performing the operation.
responses:
'200':
description: Action alias match pattern
Expand Down

0 comments on commit 3f46cab

Please sign in to comment.