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

version 3.8.0 release #1064

Merged
merged 1 commit into from Jul 15, 2021
Merged

version 3.8.0 release #1064

merged 1 commit into from Jul 15, 2021

Conversation

seratch
Copy link
Member

@seratch seratch commented Jul 15, 2021

Summary

We are going to ship a new minor version soon. Here is the draft of the release note for v3.8.0.

## New Features

### Token Rotation Support (more info to come soon!)

This version includes the support for the apps enabling the newly released token rotation for better security. Refer to [the API document](https://api.slack.com/) for the general information about the feature.

#### How to handle token rotation with this SDK

Apart from the column additions for the feature (specifically, refresh token + expiration date time) and the corresponding changes in your app code, no significant code is needed. Checking the example apps using Flask, Sanic in [this directory](https://github.com/slackapi/python-slack-sdk/tree/main/integration_tests/samples/token_rotation) can be helpful to learn what to do.

In a nutshell, you can call the following `rotate_tokens` method before handling every single incoming request from Slack. As long as your `InstallationStore` support the token rotation patterns, the code below should work as-is. 

```python
from slack_sdk.oauth.token_rotation import TokenRotator
from slack_sdk.oauth.installation_store import FileInstallationStore

# This instance can be singleton; thread-safe
token_rotator = TokenRotator(
    # These are required for refreshing tokens
    client_id=client_id,
    client_secret=client_secret,
)
# Your own InstallationStore here
installation_store = FileInstallationStore()

def rotate_tokens(
    enterprise_id: Optional[str] = None,
    team_id: Optional[str] = None,
    user_id: Optional[str] = None,
    is_enterprise_install: Optional[bool] = None,
):
    installation = installation_store.find_installation(
        enterprise_id=enterprise_id,
        team_id=team_id,
        user_id=user_id,
        is_enterprise_install=is_enterprise_install,
    )
    if installation is not None:
        # If rotation does not occur, refreshed_installation is None
        refreshed_installation = token_rotator.perform_token_rotation(installation=installation)
        if refreshed_installation is not None:
            # Save the new access token for the following processes
            installation_store.save(refreshed_installation)
# TODO: remove this comment ```

#### Migration guide for `SQLAlchemyInstallationStore` users

If your app uses the built-in `SQLAlchemyInstallationStore` for managing Slack app installations, adding the following database columns is required for this version upgrade. Refer to [the code](https://github.com/slackapi/python-slack-sdk/tree/main/slack_sdk/oauth/installation_store/sqlalchemy) to check the complete ones. 

Also, since this version, all the table columns for string data have their max length for better compatibility with MySQL. We recommend setting the same ones for your models.

##### slack_installations

* `Column("bot_refresh_token", String(200)),  # added in v3.8.0`
* `Column("bot_token_expires_at", DateTime),  # added in v3.8.0`
* `Column("user_refresh_token", String(200)),  # added in v3.8.0`
* `Column("user_token_expires_at", DateTime),  # added in v3.8.0`

##### slack_bots

* `Column("bot_refresh_token", String(200)),  # added in v3.8.0`
* `Column("bot_token_expires_at", DateTime),  # added in v3.8.0`

## Changes

* #1060 Add token rotation feature support - Thanks @seratch
* #1040 Set max length for string columns in SQLAlchemy models for MySQL compatibility - Thanks @tattee
* #1047 Make WebhookClient (sync/async) #send method accept link unfurl params - Thanks @srajiang 
* #1061 WebClient's paginated response iterator does not work for admin.conversations.search API - Thanks @seratch 
* #1054 #1053 conversations_invite() fails with "error: no_user" - Thanks @seratch @noperator 
* #1044 Updates PythOnBoardingBot tutorial sample to use bolt-python - Thanks @srajiang 
* #1048 Update command in maintainers guide - Thanks @srajiang 

---
* All issues/pull requests: https://github.com/slackapi/python-slack-sdk/milestone/38?closed=1
* All changes: https://github.com/slackapi/python-slack-sdk/compare/v3.7.0...v3.8.0

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs-src (Documents, have you run ./docs.sh?)
  • /docs-src-v2 (Documents, have you run ./docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

@codecov
Copy link

codecov bot commented Jul 15, 2021

Codecov Report

Merging #1064 (72cf13e) into main (dcf1c7c) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1064   +/-   ##
=======================================
  Coverage   84.14%   84.14%           
=======================================
  Files          99       99           
  Lines        9239     9239           
=======================================
  Hits         7774     7774           
  Misses       1465     1465           
Impacted Files Coverage Δ
slack_sdk/version.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcf1c7c...72cf13e. Read the comment docs.

@seratch seratch marked this pull request as ready for review July 15, 2021 21:53
@seratch seratch merged commit 8bbb5d4 into slackapi:main Jul 15, 2021
@seratch seratch deleted the version-3.8.0 branch July 15, 2021 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant