openid_connect_client 0.1.4 → 0.1.5
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 +4 -4
- data/README.md +30 -7
- data/lib/openid_connect_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 734f7900f1c5083d5377c341794e8971ddd5b07a
|
|
4
|
+
data.tar.gz: 1e5a15948140a93b3dcdc3f7c1b79926e19ceae1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
-
|
|
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
|
-
|
|
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
|
```
|