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

get_valid_org_auth_tokens #531

Merged
merged 1 commit into from
Jun 29, 2024
Merged

get_valid_org_auth_tokens #531

merged 1 commit into from
Jun 29, 2024

Conversation

ykeremy
Copy link
Contributor

@ykeremy ykeremy commented Jun 29, 2024

<!-- ELLIPSIS_HIDDEN -->
🚀 This description was created by Ellipsis for commit d106a04

Summary:

Added scripts and database client functions to rotate and expire outdated API keys for all organizations.

Key points:

  • Added get_all_organizations and invalidate_auth_token in cloud/db/db_client.py.
  • Created scripts/rotate_apikeys.py to rotate API keys for all organizations.
    • Uses cloud_db_client.get_all_organizations to fetch organizations.
    • Calls create_org_api_token for each organization.
  • Created scripts/expire_outdated_apikeys.py to expire outdated API keys for all organizations.
    • Uses cloud_db_client.get_all_organizations to fetch organizations.
    • Calls cloud_db_client.get_valid_org_auth_tokens and invalidate_auth_token for each organization.
  • Modified get_valid_org_auth_token in skyvern/forge/sdk/db/client.py to order tokens by creation date.
  • Added get_valid_org_auth_tokens in skyvern/forge/sdk/db/client.py to fetch valid tokens ordered by creation date.

Generated with ❤️ by ellipsis.dev

<!-- ELLIPSIS_HIDDEN -->

| 🚀 | This description was created by [Ellipsis](https://www.ellipsis.dev) for commit 28ba708ce322c6ce76e1eb2955d10e34f60680e3  |
|--------|--------|

### Summary:
Added scripts and database client functions to rotate and expire outdated API keys for all organizations.

**Key points**:
- Added `get_all_organizations` and `invalidate_auth_token` in `cloud/db/db_client.py`.
- Created `scripts/rotate_apikeys.py` to rotate API keys for all organizations.
  - Uses `cloud_db_client.get_all_organizations` to fetch organizations.
  - Calls `create_org_api_token` for each organization.
- Created `scripts/expire_outdated_apikeys.py` to expire outdated API keys for all organizations.
  - Uses `cloud_db_client.get_all_organizations` to fetch organizations.
  - Calls `cloud_db_client.get_valid_org_auth_tokens` and `invalidate_auth_token` for each organization.
- Modified `get_valid_org_auth_token` in `skyvern/forge/sdk/db/client.py` to order tokens by creation date.
- Added `get_valid_org_auth_tokens` in `skyvern/forge/sdk/db/client.py` to fetch valid tokens ordered by creation date.

----
Generated with ❤️ by [ellipsis.dev](https://www.ellipsis.dev)

<!-- ELLIPSIS_HIDDEN -->
@ykeremy ykeremy added the sync label Jun 29, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to d106a04 in 22 seconds

More details
  • Looked at 44 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/db/client.py:540
  • Draft comment:
    The implementation of get_valid_org_auth_tokens correctly fetches and orders the tokens by creation date in descending order, which is a typical requirement for token management systems to ensure the most recent tokens are used or checked first.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The PR introduces a method to fetch all valid organization authentication tokens ordered by creation date. This is a common pattern for managing API keys or tokens, especially in systems where tokens might expire or be rotated regularly. The method get_valid_org_auth_tokens retrieves all valid tokens for a given organization and token type, which is useful for identifying and managing expired tokens. The use of .order_by(OrganizationAuthTokenModel.created_at.desc()) ensures that the newest tokens are listed first, which is typically what you want when checking for the most recent, valid tokens.

Workflow ID: wflow_ql6wL1hscgBL4ITg


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on d106a04 in 27 seconds

More details
  • Looked at 43 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/db/client.py:540
  • Draft comment:
    The implementation of get_valid_org_auth_tokens correctly fetches all valid tokens for a given organization and token type, ordered by creation date. This method complements the existing get_valid_org_auth_token by providing a bulk fetch capability, which could be useful in scenarios where multiple tokens need to be managed or invalidated at once.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The PR introduces a new method get_valid_org_auth_tokens which is similar to the existing get_valid_org_auth_token but returns a list of tokens instead of a single token. Both methods order the tokens by creation date in descending order, which is a logical approach to get the most recent tokens first. This is consistent with typical use cases where the most recent token is usually the most relevant. The implementation uses SQLAlchemy's scalars() method to execute the query and fetch the results, which is appropriate for this type of database operation. The error handling is consistent with the rest of the codebase, logging and re-raising exceptions as needed.

Workflow ID: wflow_9pTeqeeP2Yk5y37g


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@wintonzheng wintonzheng changed the title script to add api keys get_valid_org_auth_tokens Jun 29, 2024
@wintonzheng wintonzheng merged commit 6a6119b into main Jun 29, 2024
2 checks passed
@wintonzheng wintonzheng deleted the shu/migrate_api_keys branch June 29, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants