Class: Openid

Inherits:
Object
  • Object
show all
Defined in:
lib/openid/openid.rb

Direct Known Subclasses

OpenidSt

Instance Method Summary collapse

Constructor Details

#initialize(verify_url, state) ⇒ Openid

Returns a new instance of Openid.



6
7
8
9
10
# File 'lib/openid/openid.rb', line 6

def initialize verify_url, state
  @verify_url = verify_url
  @key = state.keys.first
  @name = state.values.first[:name].to_sym
end

Instance Method Details

#auth_request(step = :step1) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/openid/openid.rb', line 12

def auth_request step = :step1

  uri = URI CONFIG[:oauth][@name][:auth][step][:uri]
  params = CONFIG[:oauth][@name][:auth][:united_params].merge(CONFIG[:oauth][@name][:auth][step].except(:uri)).merge({'openid.return_to' => @verify_url, 'openid.state' => @key})
  uri.query = URI.encode_www_form params
  uri.to_s

end

#error_response(error_message) ⇒ Object



39
40
41
42
43
44
# File 'lib/openid/openid.rb', line 39

def error_response error_message
  {
      state: :shit,
      error: error_message
  }
end

#oauth_access_card_params(id) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/openid/openid.rb', line 21

def oauth_access_card_params id
  begin
    {
      state: :ok,
      oauth_name: @name,
      oauth_uid: id,
      access_token: nil,
      token_expired: nil,
      photourl: nil
    }
  rescue Exception => error
    {
        state: :shit,
        error: error.message
    }
  end
end