GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mimiquate/slack_request: 🔐 Verify Slack HQ webhooks in Elixir

BranchesTags
Open more actions menu

Latest commit

 

History

64 Commits
64 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
blend
blend
 
 
lib
lib
 
 
test
test
 
 
.formatter.exs
.formatter.exs
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
blend.exs
blend.exs
 
 
mix.exs
mix.exs
 
 
mix.lock
mix.lock
 
 

Repository files navigation

🔐 SlackRequest

Utilities for verifing an HTTP request can be authenticated as a request coming from Slack HQ.

https://api.slack.com/authentication/verifying-requests-from-slack

Installation

If available in Hex, the package can be installed by adding slack_request to your list of dependencies in mix.exs:

def deps do
  [
    {:slack_request, "~> 1.0.0"}
  ]
end

Usage

Plug

Set body_reader: in Plug.Parsers inside your Endpoint.

# lib/your_app_web/endpoint.ex

defmodule YourAppWeb.Endpoint do
  ...

  plug Plug.Parsers,
    ...
    body_reader: {SlackRequest.BodyReader, :read_and_cache_body, []}
end

Plug the SlackRequest.Plug in the pipeline that handles your Slack Requests/Webhooks.

Example:

# lib/your_app_web/router.ex

defmodule YourAppWeb.Router do

  ...

  pipeline :slack do
    plug :accepts, ["json"]
    plug SlackRequest.Plug
  end

  scope "/slack", YourAppWeb do
    pipe_through :slack

    ...
  end

Manual

Or if just prefer to use the validation function directly:

# Somewhere were you're ready to validate the incoming request conn

if SlackRequest.valid_request?(conn, secret: signing_secret, body: raw_request_body) do
  # all good
else
  # handle invalid slack request/webhook
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/slack_request.

License

Copyright 2024 Mimiquate

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

🔐 Verify Slack HQ webhooks in Elixir

hex.pm/packages/slack_request

Topics

signature-verificationslackslack-webhookwebhook

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

6 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.