authrocket 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b17e31eeb3943dc100783d38ec98995fdc4a486a
4
- data.tar.gz: ec7c9240dccd849b7c35a221c52a333bab0d4cc3
3
+ metadata.gz: 7c054a38d59b78ebb06c889ca6aac2b4c6b50805
4
+ data.tar.gz: fdd903042c19e81a680f59c53046b1f6a161ed59
5
5
  SHA512:
6
- metadata.gz: 55f52ad66472cfbea2911dec7bf6f0dcd47d80aa75701e44603bedab9677fed84c9c1335b027b9cbdcd6af7568fb8468b6dd61c573943403b967859d5e0dd77c
7
- data.tar.gz: 75bd5dbe7a919f28853aa2f4260042c0676ec05cfa8d75e3e65ea6d8e9b755e10497b6e2c24b46aa77968613a1e370a4a30a6f46fad88d696de2f19d5a419390
6
+ metadata.gz: 5202950282c56717b58192d753844fd3240cbf61b5ece558f8922325c810dabbc38bdc7642941a8bb91473fc97f1f7ad8c71258c0804de05529eed708a4dbaf7
7
+ data.tar.gz: b0e99ca0dabf5c8a0b8acb468c1b199623376df9768b2f755e35ce06fa0d734795440ff00fc70aac334989e76ef2f92a636f91a54bc97d9afccce487a4c3a638
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ #### 1.4.0
2
+ - Support social auth in AuthProvider and Credential.
3
+
1
4
  #### 1.3.1
2
5
  - Add Realm#api_key_minutes
3
6
  - Add Session#client
@@ -1,3 +1,3 @@
1
1
  module AuthRocket
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -4,8 +4,49 @@ module AuthRocket
4
4
 
5
5
  belongs_to :realm
6
6
 
7
- attr :provider_type
7
+ attr :provider_type, :state
8
8
  attr :login, :name_field, :signup
9
+ attr :client_id, :client_secret, :scopes
10
+
11
+
12
+ # attribs - :redirect_uri - required
13
+ # - :nonce - optional
14
+ def self.authorize_urls(attribs={}, api_creds=nil)
15
+ parsed, creds = request(:get, url+'/authorize', api_creds, attribs)
16
+ if parsed[:errors].any?
17
+ raise Error, parsed[:errors].inspect
18
+ end
19
+ NCore::Collection.new.tap do |coll|
20
+ coll.metadata = parsed[:metadata]
21
+ parsed[:data].each do |hash|
22
+ coll << GenericObject.new(hash.merge(metadata: parsed[:metadata]), creds)
23
+ end
24
+ end
25
+ end
26
+
27
+ # attribs - :redirect_uri - required
28
+ # - :nonce - optional
29
+ def self.authorize_url(auth_provider_id, attribs={}, api_creds=nil)
30
+ parsed, creds = request(:get, url+"/#{auth_provider_id}/authorize", api_creds, attribs)
31
+ if parsed[:errors].any?
32
+ raise Error, parsed[:errors].inspect
33
+ end
34
+ parsed[:data][:url]
35
+ end
36
+
37
+ # same as self.authorize_url(self.id, ...)
38
+ def authorize_url(attribs={})
39
+ self.class.authorize_url(id, attribs, api_creds)
40
+ end
41
+
42
+ # attribs - :code - required
43
+ # - :nonce - optional
44
+ # - :state - required
45
+ # always returns a new object; check .errors? or .valid? to see how it went
46
+ def self.authorize(attribs={}, api_creds=nil)
47
+ parsed, creds = request(:post, url+'/authorize', api_creds, attribs)
48
+ User.new(parsed, creds)
49
+ end
9
50
 
10
51
  end
11
52
  end
@@ -2,10 +2,13 @@ module AuthRocket
2
2
  class Credential < Resource
3
3
  crud :find, :create, :update, :delete
4
4
 
5
+ belongs_to :auth_provider
5
6
  belongs_to :user
6
7
 
7
- attr :api_key, :credential_type
8
+ attr :credential_type
9
+ attr :api_key
8
10
  attr :password, :password_confirmation
11
+ attr :access_token, :provider_user_id, :token_expires_at
9
12
 
10
13
  end
11
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authrocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ncore