A python package that authenticates that the request is coming from slack
Project description
Slack Request Permission
Installation
- Compatibility
Python Version > 3.5
Django Version > 2.0
- Install using
pip install slack-request-permission
Introduction
Every slack app that needs to interact with any server needs to be verified (verify if the sender is actually slack).
This package offers you:
- Out-of-the-box
Djangopermission class that can be used to authenticate slack requests - Framework for creating your own permission class for any slack app
- A standalone method to verify slack request
Out-of-the-box
To use out of the box permission class, all you have to do is add the class into permission classes of Django Rest Framework.
class RandomSlackRequestView(APIView):
permission_classes = (IsSlackAppRequest,)
In settings.py
SLACK_APP_VERSION = 'v0'
SLACK_APP_SIGNING_SECRET = {YOUR_SLACK_APP_SIGNING_SECRET}
The view will verify that the incoming request is from slack before running anything.
Framework
There might come a use case where you have different slack apps with different signing_secrets interacting with your
backend. In that case, you can create your own custom permission class
from slack_request_validator.abstract_permission import AbstractIsSlackAppRequest
class MySlackApp1Permission(AbstractIsSlackAppRequest):
SLACK_APP_VERSION = 'v0'
SLACK_APP_SIGNING_SECRET = {MySlackApp1_SIGNING_SECRET}
class MySlackApp2Permission(AbstractIsSlackAppRequest):
SLACK_APP_VERSION = 'v0'
SLACK_APP_SIGNING_SECRET = {MySlackApp2_SIGNING_SECRET}
These permissions can be then used inside any Django Rest Framework's View
class MySlackApp1View(APIView):
permission_classes = (MySlackApp1Permission,)
class MySlackApp2View(APIView):
permission_classes = (MySlackApp2Permission,)
Standalone-Method
There might be cases when you don't want to use permission classes. You can directly use the method that verifies slack request
This method returns either True or False
True # If slack request is correct
False # If slack request is incorrect
from slack_request_validator.utils import verify_slack_request
slack_version = 'v0'
slack_app_signing_secret = {YOUR_SLACK_APP_SIGNING_SECRET}
verify_slack_request(request=request, slack_app_version=slack_version, slack_app_signing_secret=slack_app_signing_secret)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slack-request-permission-1.0.6.tar.gz.
File metadata
- Download URL: slack-request-permission-1.0.6.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fba3d3e9fa33b126b3097dd9544e40e3071092fa7e3877c73f669f543bcde88
|
|
| MD5 |
00edc84ec28b61be39fc8ffc0560725e
|
|
| BLAKE2b-256 |
5b3b841d12ad5c6d0466095b0a242670233019d500d414c8017d4ce00ad7947b
|
File details
Details for the file slack_request_permission-1.0.6-py3-none-any.whl.
File metadata
- Download URL: slack_request_permission-1.0.6-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fe951993e028d9dd56bca6bdf985d20701e80f812ddcef60966ba0ad3bf3620
|
|
| MD5 |
dbf3bde80bc9fc2af9ddb3b1d32aa3d8
|
|
| BLAKE2b-256 |
370f0f38875993ec89480b21536eb307b2aa16741e551b70cfe8901951e90c76
|