Class: OmniAuth::Strategies::SlackOpenid

Inherits:
OAuth2
  • Object
show all
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 =

Returns:

  • (Array[Symbol])
%i[scope team].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generate_uid(team_id, user_id) ⇒ String

Parameters:

  • team_id (String, nil)
  • user_id (String, nil)

Returns:

  • (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_paramsHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


78
79
80
81
82
83
84
85
# File 'lib/omniauth/strategies/slack_openid.rb', line 78

def authorize_params
  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_urlString

Returns:

  • (String)


87
88
89
# File 'lib/omniauth/strategies/slack_openid.rb', line 87

def callback_url
  options.redirect_uri || (full_host + script_name + callback_path)
end

#fetch_and_validate_user_infoHash[String, untyped]

Returns:

  • (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 
  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_infoHash[String, untyped]

Returns:

  • (Hash[String, untyped])


91
92
93
# File 'lib/omniauth/strategies/slack_openid.rb', line 91

def raw_info
  @raw_info ||= 
end