From e113e2c37ed5eeaed7592f866e9cb7be1bacc5c1 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 27 Nov 2015 18:12:40 -0500 Subject: [PATCH] Allow restricting login to a specific team ID --- README.md | 13 +++++++++++++ lib/ueberauth/strategy/slack.ex | 3 +++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 7f5c84c..bfb9641 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,19 @@ ] ``` + You can optionally restrict authentication by providing your team ID. [Find your Slack team ID here](https://api.slack.com/methods/auth.test/test). Note that this is NOT your team's Slack domain name! + + ```elixir + config :ueberauth, Ueberauth, + providers: [ + slack: [ + {Ueberauth.Strategy.Slack, [ + team: "0ABCDEF" + ]} + ] + ] + ``` + 1. Update your provider configuration: ```elixir diff --git a/lib/ueberauth/strategy/slack.ex b/lib/ueberauth/strategy/slack.ex index c92eab8..bfdee2f 100644 --- a/lib/ueberauth/strategy/slack.ex +++ b/lib/ueberauth/strategy/slack.ex @@ -31,6 +31,9 @@ defmodule Ueberauth.Strategy.Slack do if conn.params["state"], do: opts = Keyword.put(opts, :state, conn.params["state"]) callback_url = callback_url(conn) + team = option(conn, :team) + if team, do: opts = Keyword.put(opts, :team, team) + if String.ends_with?(callback_url, "?"), do: callback_url = String.slice(callback_url, 0..-2) opts = Keyword.put(opts, :redirect_uri, callback_url)