openid_connect_client 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a04420f4fb5cb30857d4c300665ea22be333e357
4
- data.tar.gz: 567b669805a9105c167f12af02aa90c208239381
3
+ metadata.gz: 734f7900f1c5083d5377c341794e8971ddd5b07a
4
+ data.tar.gz: 1e5a15948140a93b3dcdc3f7c1b79926e19ceae1
5
5
  SHA512:
6
- metadata.gz: c460a20702cd1039dc2624ce76b9aae80a7aa8e8c911ce151d06d2df7e0ed82deb65e6498d7dc8eb420985092251ef1452be274ea67184cccb528aa19d7006ad
7
- data.tar.gz: 86198e72f63dadbbe5e73745e2014f556e36f168c454df587efda5fcb6ff0ef72d54ad9fd878f0550a6d526af16998da31c40aafebc5f6bccad3197d2c5c52ba
6
+ metadata.gz: 22b7911f77c68683377b106a9d63d3178d46c7ad155436c21db5a691acc757bbff8ca92c24ca9348d52d9fcad59a6509d61789e04975b66b1e3a691009d5cf38
7
+ data.tar.gz: 97d68d92a168f60a4da6bb6c036973366aef0c38095d0cfc33c811d23b4a8d2752d1a3ee4a647f09f80044ef4e88e95c147893dc81eb62e7ebcddfdfd06e4f4b
data/README.md CHANGED
@@ -3,30 +3,53 @@
3
3
  A literal, not so idiomatic ruby port of Michael Jett's excellent [OpenID Connect](https://github.com/jumbojett/OpenID-Connect-PHP) library for PHP.
4
4
 
5
5
  ## Requirements
6
- - Curb
6
+ - [curb](https://github.com/taf2/curb)
7
+
8
+ ## Installation
9
+ ```
10
+ gem install openid_connect_client
11
+ ```
7
12
 
8
13
  ## Usage
14
+ The process is just like oAuth authentication. It's done in two steps: first, you'll request authorization, and redirect the user to the OpenID Connect provider. If your app gets authorized, then the provider will redirect the user back to your callback url, where you'll be able to ask the provider for the user data.
15
+
9
16
  See `example.rb`
10
- ```
17
+
18
+ ### On the login controller
19
+ ```ruby
20
+ # 1. Client setup, ideally done in a helper method
11
21
  oidc = OpenIDConnectClient::Client.new('https://provider.com/openid', 'CLIENT_ID', 'SECRET')
12
22
  oidc.redirect_url = "http://yourweb.com/callback"
13
23
  oidc.scopes = "openid email profile address phone"
14
24
 
25
+ # 2. Request authorization
15
26
  oidc.authorize()
16
-
27
+
28
+ # 3. Save state in session
17
29
  session[:state] = oidc.state
30
+
31
+ # 4. Redirect user to OpenID Connect provider
18
32
  redirect_to(oidc.auth_endpoint)
19
33
  ```
20
34
 
21
- ### On the callback
22
- ```
35
+ ### On the callback controller
36
+ ```ruby
37
+ # 1. Client setup, ideally done in a helper method
23
38
  oidc = OpenIDConnectClient::Client.new('https://provider.com/openid', 'CLIENT_ID', 'SECRET')
24
39
  oidc.redirect_url = "http://yourweb.com/callback"
25
40
  oidc.scopes = "openid email profile address phone"
26
41
 
42
+ # 2. Restore state
43
+ oidc.state = session[:state]
44
+
45
+ # 3. Pass the authorization parameters sent by the provider
46
+ oidc.params = request.parameters
47
+
48
+ # 4. Authenticate your app against the provider
27
49
  oidc.authenticate()
28
-
29
- email = oidc.get('email')
50
+
51
+ # 5. Fetch the user's details
30
52
  given_name = oidc.get('given_name')
53
+ email = oidc.get('email')
31
54
  address = oidc.get('address')
32
55
  ```
@@ -1,3 +1,3 @@
1
1
  module OpenIDConnectClient
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openid_connect_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rita Zerrizuela