Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Marketplace Contribution] Okta - Content Pack Update #29303

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions Packs/Okta/Integrations/Okta_v2/Okta_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ def set_temp_password(self, user_id):
url_suffix=uri,
)

def expire_password(self, user_id):
uri = f'users/{user_id}/lifecycle/expire_password'
return self._http_request(
method="POST",
url_suffix=uri
)

def add_user_to_group(self, user_id, group_id):
uri = f'groups/{group_id}/users/{user_id}'
return self._http_request(
Expand Down Expand Up @@ -804,6 +811,30 @@ def set_password_command(client, args):
)


def expire_password_command(client, args):
user_id = client.get_user_id(args.get('username'))

if not (args.get('username') or user_id):
raise Exception("You must supply either 'Username' or 'userId")
Comment on lines +815 to +818
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this secnario we should first check we have a valid username, and then try to get the UserId. if we can't get a userId an eception is thrown form the get_user_id function. I changed the exception a bit accordingly. WDYT?

Suggested change
user_id = client.get_user_id(args.get('username'))
if not (args.get('username') or user_id):
raise Exception("You must supply either 'Username' or 'userId")
if not args.get('username'):
raise Exception("You must supply a valid username to use this command")
user_id = client.get_user_id(args.get('username'))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ostolero,

I think you may have tagged the wrong individual, no worries :)

Regarding your proposed changes, this was definitely an oversight on my end and glad that you pointed it out. I agree that it would be better to handle the error and raise an exception before running the get_user_id method.

Also, I went ahead and provided access to the MP4 file -- please view at your earliest convenience. Thanks!


raw_response = client.expire_password(user_id)
user_context = client.get_users_context(raw_response)

if argToBoolean(args.get('temporary_password', True)):
client.set_temp_password(user_id)

readable_output = tableToMarkdown('Okta Expired Password', raw_response, removeNull=True)
outputs = {
'Okta.ExpiredPassword': createContext(user_context, removeNull=True)
}

return (
readable_output,
outputs,
raw_response
)


def add_user_to_group_command(client, args):
group_id = args.get('groupId')
user_id = args.get('userId')
Expand Down Expand Up @@ -1353,6 +1384,7 @@ def main():
'okta-unsuspend-user': unsuspend_user_command,
'okta-reset-factor': reset_factor_command,
'okta-set-password': set_password_command,
'okta-expire-password': expire_password_command,
'okta-add-to-group': add_user_to_group_command,
'okta-remove-from-group': remove_from_group_command,
'okta-get-groups': get_groups_for_user_command,
Expand Down
28 changes: 21 additions & 7 deletions Packs/Okta/Integrations/Okta_v2/Okta_v2.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Authentication & Identity Management

Check failure on line 1 in Packs/Okta/Integrations/Okta_v2/Okta_v2.yml

View workflow job for this annotation

GitHub Actions / pre-commit

Validation Error RM110

The following commands appear in Okta_v2.yml but not in the README file: okta-expire-password
sectionOrder:
- Connect
- Collect
Expand All @@ -17,6 +17,7 @@
hiddenusername: true
section: Connect
required: false
display: ''
- display: API Token (see detailed instructions)
name: apitoken
type: 4
Expand Down Expand Up @@ -212,10 +213,8 @@
- default: true
description: Term by which to search. Can be a first name, last name, or email address. The argument `term` or `advanced_search` is required.
name: term
required: false
- description: Searches for users with a supported filtering expression for most properties, including custom-defined properties. The argument `term` or `advanced_search` is required.
name: advanced_search
required: false
- description: The maximum number of results to return. The default and maximum is 200.
name: limit
- auto: PREDEFINED
Expand Down Expand Up @@ -322,7 +321,7 @@
- 'false'
- description: Searches the name property of groups for matching values.
name: query
- description: "Useful for performing structured queries where constraints on group attribute values can be explicitly targeted. \nThe following expressions are supported(among others) for groups with the filter query parameter: \ntype eq \"OKTA_GROUP\" - Groups that have a type of OKTA_GROUP; lastUpdated lt \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with profile last updated before a specific timestamp; lastMembershipUpdated eq \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with memberships last updated at a specific timestamp; id eq \"00g1emaKYZTWRYYRRTSK\" - Group with a specified ID. For more information about filtering, visit https://developer.okta.com/docs/api/getting_started/design_principles#filtering"
- description: "Useful for performing structured queries where constraints on group attribute values can be explicitly targeted. \nThe following expressions are supported(among others) for groups with the filter query parameter: \n type eq \"OKTA_GROUP\" - Groups that have a type of OKTA_GROUP; lastUpdated lt \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with profile last updated before a specific timestamp; lastMembershipUpdated eq \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with memberships last updated at a specific timestamp; id eq \"00g1emaKYZTWRYYRRTSK\" - Group with a specified ID. For more information about filtering, visit https://developer.okta.com/docs/api/getting_started/design_principles#filtering"
name: filter
description: Lists users in your organization.
name: okta-list-users
Expand Down Expand Up @@ -616,7 +615,7 @@
- arguments:
- description: Searches the name property of groups for matching values.
name: query
- description: "Useful for performing structured queries where constraints on group attribute values can be explicitly targeted. \nThe following expressions are supported(among others) for groups with the filter query parameter: \ntype eq \"OKTA_GROUP\" - Groups that have a type of OKTA_GROUP; lastUpdated lt \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with profile last updated before a specific timestamp; lastMembershipUpdated eq \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with memberships last updated at a specific timestamp; id eq \"00g1emaKYZTWRYYRRTSK\" - Group with a specified ID. For more information about filtering, visit https://developer.okta.com/docs/api/getting_started/design_principles#filtering"
- description: "Useful for performing structured queries where constraints on group attribute values can be explicitly targeted. \nThe following expressions are supported(among others) for groups with the filter query parameter: \n type eq \"OKTA_GROUP\" - Groups that have a type of OKTA_GROUP; lastUpdated lt \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with profile last updated before a specific timestamp; lastMembershipUpdated eq \"yyyy-MM-dd''T''HH:mm:ss.SSSZ\" - Groups with memberships last updated at a specific timestamp; id eq \"00g1emaKYZTWRYYRRTSK\" - Group with a specified ID. For more information about filtering, visit https://developer.okta.com/docs/api/getting_started/design_principles#filtering"
name: filter
- defaultValue: '200'
description: The maximum number of results to return. The default is 200.
Expand Down Expand Up @@ -1406,11 +1405,26 @@
name: appName
description: Assign a group to an application
name: okta-assign-group-to-app
dockerimage: demisto/python3:3.10.12.68714
- arguments:
- default: true
description: Okta username for which to expire the password.
name: username
required: true
- auto: PREDEFINED
defaultValue: 'false'
description: When true, you'll need to change the password in the next login.
name: temporary_password
predefined:
- 'true'
- 'false'
description: Expires a password for an existing Okta user.
execution: true
name: okta-expire-password
dockerimage: demisto/python3:3.10.13.72123
runonce: false
script: '-'
script: ""
subtype: python3
type: python
fromversion: 5.0.0
tests:
- OktaV2-Test
- OktaV2-Test
6 changes: 1 addition & 5 deletions Packs/Okta/Integrations/Okta_v2/Okta_v2_description.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Okta V2
-
For information on getting your Okta API token, see the Okta documentation.
https://developer.okta.com/docs/api/getting_started/getting_a_token


---
[View Integration Documentation](https://xsoar.pan.dev/docs/reference/integrations/okta-v2)
https://developer.okta.com/docs/api/getting_started/getting_a_token
7 changes: 7 additions & 0 deletions Packs/Okta/ReleaseNotes/3_2_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Integrations

##### Okta v2

- Added the okta-expire-password command which allows users to expire passwords for Okta users.
- Updated the Docker image to: *demisto/python3:3.10.13.72123*.
2 changes: 1 addition & 1 deletion Packs/Okta/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Okta",
"description": "Integration with Okta's cloud-based identity management service.",
"support": "xsoar",
"currentVersion": "3.1.29",
"currentVersion": "3.2.0",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down