Class: AuthRocket::AuthProvider

Inherits:
Resource
  • Object
show all
Defined in:
lib/authrocket/auth_provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_urlObject (readonly)

readonly



13
14
15
# File 'lib/authrocket/auth_provider.rb', line 13

def auth_url
  @auth_url
end

#authorization_urlObject (readonly)

Returns the value of attribute authorization_url.



11
12
13
# File 'lib/authrocket/auth_provider.rb', line 11

def authorization_url
  @authorization_url
end

#client_idObject (readonly)

Returns the value of attribute client_id.



9
10
11
# File 'lib/authrocket/auth_provider.rb', line 9

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



9
10
11
# File 'lib/authrocket/auth_provider.rb', line 9

def client_secret
  @client_secret
end

#email_fieldObject (readonly)

Returns the value of attribute email_field.



12
13
14
# File 'lib/authrocket/auth_provider.rb', line 12

def email_field
  @email_field
end

#email_verified_fieldObject (readonly)

Returns the value of attribute email_verified_field.



12
13
14
# File 'lib/authrocket/auth_provider.rb', line 12

def email_verified_field
  @email_verified_field
end

#first_name_fieldObject (readonly)

Returns the value of attribute first_name_field.



12
13
14
# File 'lib/authrocket/auth_provider.rb', line 12

def first_name_field
  @first_name_field
end

#id_fieldObject (readonly)

Returns the value of attribute id_field.



12
13
14
# File 'lib/authrocket/auth_provider.rb', line 12

def id_field
  @id_field
end

#last_name_fieldObject (readonly)

Returns the value of attribute last_name_field.



12
13
14
# File 'lib/authrocket/auth_provider.rb', line 12

def last_name_field
  @last_name_field
end

#loginrocket_domainObject (readonly)

Returns the value of attribute loginrocket_domain.



10
11
12
# File 'lib/authrocket/auth_provider.rb', line 10

def loginrocket_domain
  @loginrocket_domain
end

#min_complexityObject (readonly)

Returns the value of attribute min_complexity.



8
9
10
# File 'lib/authrocket/auth_provider.rb', line 8

def min_complexity
  @min_complexity
end

#min_lengthObject (readonly)

Returns the value of attribute min_length.



8
9
10
# File 'lib/authrocket/auth_provider.rb', line 8

def min_length
  @min_length
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/authrocket/auth_provider.rb', line 7

def name
  @name
end

#name_fieldObject (readonly)

Returns the value of attribute name_field.



12
13
14
# File 'lib/authrocket/auth_provider.rb', line 12

def name_field
  @name_field
end

#profile_urlObject (readonly)

Returns the value of attribute profile_url.



11
12
13
# File 'lib/authrocket/auth_provider.rb', line 11

def profile_url
  @profile_url
end

#provider_typeObject (readonly)

Returns the value of attribute provider_type.



7
8
9
# File 'lib/authrocket/auth_provider.rb', line 7

def provider_type
  @provider_type
end

#required_charsObject (readonly)

Returns the value of attribute required_chars.



8
9
10
# File 'lib/authrocket/auth_provider.rb', line 8

def required_chars
  @required_chars
end

#scopesObject (readonly)

Returns the value of attribute scopes.



9
10
11
# File 'lib/authrocket/auth_provider.rb', line 9

def scopes
  @scopes
end

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/authrocket/auth_provider.rb', line 7

def state
  @state
end

#token_urlObject (readonly)

Returns the value of attribute token_url.



11
12
13
# File 'lib/authrocket/auth_provider.rb', line 11

def token_url
  @token_url
end

Class Method Details

.authorize(attribs = {}) ⇒ Object

attribs - :code - required

- :nonce - optional
- :state - required

returns: Session always returns a new object; check .errors? or .valid? to see how it went



63
64
65
66
67
# File 'lib/authrocket/auth_provider.rb', line 63

def authorize(attribs={})
  params = parse_request_params(attribs)
  parsed, creds = request(:post, resource_path+'/authorize', params)
  factory(parsed, creds)
end

.authorize_url(auth_provider_id, attribs = {}) ⇒ Object

attribs - :redirect_uri - required

- :nonce        - optional

returns: simplified AuthProvider

Raises:

  • (QueryError)


51
52
53
54
55
56
# File 'lib/authrocket/auth_provider.rb', line 51

def authorize_url(auth_provider_id, attribs={})
  params = parse_request_params(attribs)
  parsed, creds = request(:get, resource_path+"/#{CGI.escape auth_provider_id}/authorize", params)
  raise QueryError, parsed[:errors] if parsed[:errors].any?
  factory(parsed, creds)
end

.authorize_urls(attribs = {}) ⇒ Object

attribs - :redirect_uri - required

- :nonce        - optional

returns: Array of simplified AuthProviders

Raises:

  • (QueryError)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/authrocket/auth_provider.rb', line 36

def authorize_urls(attribs={})
  params = parse_request_params(attribs)
  parsed, creds = request(:get, resource_path+'/authorize', params)
  raise QueryError, parsed[:errors] if parsed[:errors].any?
  NCore::Collection.new.tap do |coll|
    coll. = parsed[:metadata]
    parsed[:data].each do |hash|
      coll << factory({data: hash, metadata: parsed[:metadata]}, creds)
    end
  end
end

Instance Method Details

#authorize_token(attribs = {}) ⇒ Object

attribs - :access_token - required returns: Session always returns a new object; check .errors? or .valid? to see how it went



24
25
26
27
28
# File 'lib/authrocket/auth_provider.rb', line 24

def authorize_token(attribs={})
  params = parse_request_params(attribs)
  parsed, creds = request(:post, resource_path+'/authorize', params)
  self.class.factory(parsed, creds)
end

#authorize_url(attribs = {}) ⇒ Object

same as self.authorize_url(self.id, …)



17
18
19
# File 'lib/authrocket/auth_provider.rb', line 17

def authorize_url(attribs={})
  self.class.authorize_url id, attribs.reverse_merge(credentials: api_creds)
end