Class: OmniAuth::Strategies::SlackOpenid
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::SlackOpenid
- Defined in:
- lib/omniauth/strategies/slack_openid.rb,
sig/omniauth/strategies/slack_openid.rbs
Defined Under Namespace
Classes: INFO_DATA
Constant Summary collapse
- AUTH_OPTIONS =
%i[scope team].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #authorize_params ⇒ Hash[Symbol, untyped]
- #callback_url ⇒ String
- #fetch_and_validate_user_info ⇒ Hash[String, untyped]
- #raw_info ⇒ Hash[String, untyped]
Class Method Details
.generate_uid(team_id, user_id) ⇒ String
33 34 35 36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/slack_openid.rb', line 33 def self.generate_uid(team_id, user_id) team = team_id.to_s user = user_id.to_s if team.empty? || user.empty? raise ArgumentError, "team_id and user_id are required" end "#{team}-#{user}" end |
Instance Method Details
#authorize_params ⇒ Hash[Symbol, untyped]
78 79 80 81 82 83 84 85 |
# File 'lib/omniauth/strategies/slack_openid.rb', line 78 def super.tap do |params| AUTH_OPTIONS.each do |key| value = request.params[key.to_s] params[key] = value if value && !value.to_s.empty? end end end |
#callback_url ⇒ String
87 88 89 |
# File 'lib/omniauth/strategies/slack_openid.rb', line 87 def callback_url .redirect_uri || (full_host + script_name + callback_path) end |
#fetch_and_validate_user_info ⇒ Hash[String, untyped]
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/omniauth/strategies/slack_openid.rb', line 97 def fetch_and_validate_user_info response = access_token.get("/api/openid.connect.userInfo").parsed unless response.is_a?(Hash) && response["ok"] == true error = response.is_a?(Hash) ? response["error"] : nil raise CallbackError.new( :invalid_credentials, "Slack userInfo failed#{": #{error}" if error}" ) end team_id = response["https://slack.com/team_id"].to_s user_id = response["https://slack.com/user_id"].to_s if team_id.empty? || user_id.empty? raise CallbackError.new( :invalid_credentials, "Slack userInfo missing team_id or user_id" ) end response end |
#raw_info ⇒ Hash[String, untyped]
91 92 93 |
# File 'lib/omniauth/strategies/slack_openid.rb', line 91 def raw_info @raw_info ||= fetch_and_validate_user_info end |