oxd-ruby 0.1.8 → 0.1.9

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: 3c927e7af3f706adb71804447f38b290df3cb5b1
4
- data.tar.gz: cf118779fe069f932110fc38477e990adddd6fb1
3
+ metadata.gz: a6f9d21c4d5fd1f1e0e893595e97985749bd94e8
4
+ data.tar.gz: 4fba31e51faf898d93a42180e74786ecf50598e1
5
5
  SHA512:
6
- metadata.gz: a8b71232f3ecb9c829eba9511ecf6232f7ba9429e18e1afc7f69b62b79aad9ad173e949baa2a3286c21e586f98f7c5b42e38a6408829fcd5371f6cd41f16d2f2
7
- data.tar.gz: 116fc42fff057ff8840ecc90493fd1abf4bd978dfc9c065592d7f29a53b6d53801e39fd32646a897a786109d8dc8287cb5c18ba8d167c894bd9d3d66c2018858
6
+ metadata.gz: bba06880ed389a598e3a6aae0561af20741416875fe017e8643ab3b2078ac784d56cc560a2ac7e3276febb880d092bdb54afa3cdc8742e3c2fa8594a023a90cd
7
+ data.tar.gz: 8ab4c90bdf20239d69c9c3e7b5d63bfc7d16b524e87c54d029a53b0b3c6627cf6430b2b92b8b47e8636be0353dd63cb0bfc570e39f5ee584c721e15f87cdd1e6
@@ -1,6 +1,19 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.1.9] - 2017-10-17
5
+ ### Added
6
+ - support for oxd-to-https
7
+ - Introduced UMA 2 support
8
+ - `setup_client` command
9
+ - `get_client_token` command
10
+ - `get_access_token_by_refresh_token` command
11
+ - `uma_rp_get_claims_gathering_url` UMA - RP command
12
+
13
+ ### Removed
14
+ - `uma_rp_authorize_rpt` UMA command
15
+ - `uma_rp_get_gat` UMA command
16
+
4
17
  ## [0.1.8] - 2017-05-16
5
18
  ### Added
6
19
  - support for oxd-to-http
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Oxd Ruby
2
2
  [![Gem Version](https://badge.fury.io/rb/oxd-ruby.png)](https://badge.fury.io/rb/oxd-ruby)
3
3
 
4
- Ruby Client Library for the [Gluu oxD Server RP - v2.4.4 to v3.0.1](https://www.gluu.org/docs-oxd/).
4
+ Ruby Client Library for the [Gluu oxD Server RP - v3.1.1](https://gluu.org/docs/oxd/3.1.1).
5
5
 
6
6
  **oxdruby** is a thin wrapper around the communication protocol of oxD server. This can be used to access the OpenID connect & UMA Authorization end points of the Gluu Server via the oxD RP. This library provides the function calls required by a website to access user information from a OpenID Connect Provider (OP) by using the OxD as the Relying Party (RP).
7
7
 
@@ -9,22 +9,21 @@ Ruby Client Library for the [Gluu oxD Server RP - v2.4.4 to v3.0.1](https://www.
9
9
 
10
10
  > You are now on the `master` branch. If you want to use `oxd-ruby` for production use, switch to the branch of the matching version as the `oxd-server` you are installing.
11
11
 
12
- [oxD RP](https://www.gluu.org/docs-oxd/) has complete information about the Code Authorization flow and the various details about oxD RP configuration. This document provides only documentation about the oxd-ruby library.
12
+ [oxD RP](https://gluu.org/docs/oxd/3.1.1) has complete information about the Code Authorization flow and the various details about oxD RP configuration. This document provides only documentation about the oxd-ruby library.
13
13
 
14
14
  ### Prerequisites
15
15
 
16
- * Install `gluu-oxd-server`
16
+ * A valid OpenID Connect Provider (OP), like the Gluu Server or Google.
17
+ * An active installation of the oxd-server running on the same server as the client application.
18
+ * An active installation of the oxd-https-extension if oxd-https-extension connection is used. In this case, client applications can be on different servers but will be able to access oxd-https-extension.
17
19
 
18
- Oxd-server needs to be running on your machine to connect with OP.
19
-
20
- * Enable SSL on your website otherwise this library will not work.
21
20
 
22
21
  ### Installation
23
22
 
24
23
  To install gem, add this line to your application's Gemfile:
25
24
 
26
25
  ```ruby
27
- gem 'oxd-ruby', '~> 0.1.8'
26
+ gem 'oxd-ruby', '~> 0.1.9'
28
27
  ```
29
28
 
30
29
  Run bundle command to install it:
@@ -32,22 +31,57 @@ Run bundle command to install it:
32
31
  ```bash
33
32
  $ bundle install
34
33
  ```
34
+ #### Important Links
35
+
36
+ - See the [API docs](https://gluu.org/docs/oxd/3.1.1/libraries/ruby/) for in-depth information about the various functions and their parameters.
37
+ - See the code of a [sample Ruby on Rails app](https://github.com/GluuFederation/oxd-ruby/tree/master/demosite) built using oxd-ruby.
35
38
 
36
39
  ### Configuring
40
+
37
41
  After you installed oxd-ruby, you need to run the generator command to generate the configuration file:
38
42
 
39
43
  ```bash
40
44
  $ rails generate oxd:config
41
45
  ```
42
46
 
43
- The generator will install `oxd_config.rb` initializer file in `config/initializers` directory which conatins all the global configuration options for oxd-ruby plguin.
44
- The following configurations must be set in config file before the plugin can be used.
47
+ The generator will install `oxd_config.rb` initializer file in `config/initializers` directory which conatins all the global configuration options for oxd-ruby plguin. The generated configuration file looks like this:
48
+
49
+ ```ruby
50
+ config.oxd_host_ip = '127.0.0.1'
51
+ config.oxd_host_port = 8099
52
+ config.op_host = "https://your.openid.provider.com"
53
+ config.client_id = "<client_id of OpenId provider>"
54
+ config.client_secret = "<client_secret of OpenId provider>"
55
+ config.client_name = "Gluu Oxd Sample Client"
56
+ config.authorization_redirect_uri = "https://domain.example.com/callback"
57
+ config.logout_redirect_uri = "https://domain.example.com/callback2"
58
+ config.post_logout_redirect_uri = "https://domain.example.com/logout"
59
+ config.scope = ["openid","profile", "email", "uma_protection","uma_authorization"]
60
+ config.grant_types = []
61
+ config.application_type = "web"
62
+ config.response_types = ["code"]
63
+ config.acr_values = ["basic"]
64
+ config.client_jwks_uri = ""
65
+ config.client_token_endpoint_auth_method = ""
66
+ config.client_request_uris = []
67
+ config.contacts = ["example-email@gmail.com"]
68
+ config.client_logout_uris = ['https://domain.example.com/logout']
69
+ config.oxd_host = "https://127.0.0.1:8443" set if you are using oxd-https extension
70
+ config.connection_type = "local" if you are using oxd-server without oxd-https extension otherwise "web"
71
+ config.dynamic_registration = true if the op_host supports dynamic registration otherwise 'false'
72
+ ```
73
+ The following configuration must be set in config file before the gem can be used:
45
74
 
46
- 1. config.oxd_host_ip
47
- 2. config.oxd_host_port
48
- 3. config.op_host
49
- 4. config.authorization_redirect_uri
75
+ - config.oxd_host_ip
76
+ - config.oxd_host_port
77
+ - config.op_host
78
+ - config.authorization_redirect_uri
79
+ - config.client_id
80
+ - config.client_secret
81
+ - config.connection_type
82
+ - config.oxd_host
50
83
 
84
+ **Note :** client_id and client_secret must be set if your OpenID provider does not support dynamic registration, otherwise can be left blank.
51
85
 
52
86
  ## Usage
53
87
 
@@ -61,39 +95,75 @@ protected
61
95
  def set_oxd_commands_instance
62
96
  @oxd_command = Oxd::ClientOxdCommands.new
63
97
  @uma_command = Oxd::UMACommands.new
98
+ @oxdConfig = @oxd_command.oxdConfig
64
99
  end
65
100
  ```
66
101
 
67
- The `ClientOxdCommands` class of the library provides all the methods required for the website to communicate with the oxD RP through sockets.
102
+ The `ClientOxdCommands` class of the library provides all the methods required for the website to communicate with the oxD RP through sockets. The `oxdConfig` method returns Oxd Configuration object.
68
103
  The `UMACommands` class provides commands for UMA Resource Server(UMA RS) and UMA Requesting Party(UMA RP) protocol.
69
104
 
105
+ ### Setup Client
106
+
107
+ In order to use an OpenID Connect Provider (OP) for login, you need to setup your client application at the OP. During setup oxd will dynamically register the OpenID Connect client and save its configuration. Upon successful setup a unique identifier will be issued by the oxd server by assigning a specific oxd id. Along with oxd Id oxd server will also return client Id and client secret. This client Id and client secret can be used for `get_client_token` method. The Setup Client method is a one time task to configure a client in the oxd server and OP.
108
+
109
+ **Note:** If your OpenID Connect Provider does not support dynamic registration (like Google), you will need to obtain a ClientID and Client Secret which can be set in `oxd_config.rb` initializer file.
110
+
111
+ ```ruby
112
+ @oxd_command.setup_client
113
+ ```
114
+
115
+ ### Get Client Token
116
+
117
+ The `get_client_token` method is used to get a token which is sent as `protection_access_token` for other methods when the `protect_commands_with_access_token` is enabled in oxd-server.
118
+
119
+ > `get_client_token` command must be invoked to use following methods when the `protect_commands_with_access_token` is enabled in oxd-server.
120
+
121
+ ```ruby
122
+ @oxd_command.get_client_token
123
+ ```
124
+
70
125
  ### Website Registration
71
126
 
72
- The website can be registered with the OpenId Provider using the `@oxd_command.register_site` call.
127
+ In order to use an OpenID Connect Provider (OP) for login, you need to register your client application at the OP. During registration oxd will dynamically register the OpenID Connect client and save its configuration. Upon successful registration a unique identifier will be issued by the oxd server. The Register Site method is a one time task to configure a client in the oxd server and OP.
128
+
129
+ **Note:** If your OpenID Connect Provider does not support dynamic registration (like Google), you will need to obtain a ClientID and Client Secret which can be set in `oxd_config.rb` initializer file.
130
+
131
+ ```ruby
132
+ @oxd_command.register_site
133
+ ```
73
134
 
74
135
  ### Get Authorization URL
75
136
 
76
- The first step is to generate an authorization url which the user can visit to authorize your application to use the information from the OpenId Provider.
137
+ The `get_authorization_url` method returns the OpenID Connect Provider authentication URL to which the client application must redirect the user to authorize the release of personal data. The response URL includes state value, which can be used to obtain tokens required for authentication. This state value is used
138
+ to maintain state between the request and the callback.
77
139
 
78
140
  ```ruby
79
141
  authorization_url = @oxd_command.get_authorization_url
80
142
  ```
81
- Using the above url the website can redirect the user for authentication at the OpenId Provider.
143
+ Using the above url the website can redirect the user for authentication at the OpenId Provider.
82
144
 
83
145
  ### Get access token
84
146
 
85
- The website needs to parse the information from the callback url and pass it on to get the access token for fetching user information.
147
+ Upon successful login, the login result will return code and state. `get_tokens_by_code` uses code and state to retrieve token which can be used to access user claims.
86
148
 
87
149
  ```ruby
88
150
  code = params[:code]
89
151
  state = params[:state]
90
152
  access_token = @oxd_command.get_tokens_by_code( code,state )
91
153
  ```
92
- The values for code are parsed from the callback url query parameters.
154
+ The values for code and state are parsed from the callback url query parameters.
155
+
156
+ ### Get Access Token by Refresh Token
157
+
158
+ The `get_access_token_by_refresh_token` method is used to get a fresh access token and refresh token by using the refresh token which is obtained from `get_tokens_by_code` method.
159
+
160
+ ```ruby
161
+ access_token = @oxd_command.get_access_token_by_refresh_token
162
+ ```
93
163
 
94
164
  ### Get user claims
95
165
 
96
- Claims (user information fields) made availble by the OpenId Provider can be fetched using the access token obtained above.
166
+ Once the user has been authenticated by the OpenID Connect Provider, the `get_user_info` method returns Claims (Like First Name, Last Name, emailId, etc.) about the authenticated end user. Claims (user information fields) made availble by the OpenId Provider can be fetched using the access token obtained above.
97
167
 
98
168
  ```ruby
99
169
  user = @oxd_command.get_user_info(access_token)
@@ -112,7 +182,7 @@ The availability of various claims are completely dependent on the OpenId Provid
112
182
 
113
183
  ### Logging out
114
184
 
115
- Once the required work is done the user can be logged out of the system.
185
+ Once the required work is done the user can be logged out of the system. `get_logout_uri` method returns the OpenID Connect Provider logout url.
116
186
 
117
187
  ```ruby
118
188
  logout_uri = @oxd_command.get_logout_uri(state, session_state)
@@ -123,6 +193,8 @@ You can then redirect the user to obtained url to perform logout.
123
193
 
124
194
  ### UMA Protect resources
125
195
 
196
+ `uma_rs_protect` method is used for protecting resource with UMA Resource server. Resource server need to construct the command which will protect the resource. The command will contain api path, http methods (POST,GET, PUT) and scopes. Scopes can be mapped with authorization policy (uma_rpt_policies). If no authorization policy mapped, `uma_rs_check_access` method will always return access as granted.
197
+
126
198
  To protect resources with UMA Resource server, you need to add resources to library using `uma_add_resource(path, *conditions)` method. Then you can call following method to register resources for protection with UMA RS.
127
199
 
128
200
  ```ruby
@@ -136,27 +208,31 @@ To check wether you have access to a particular resource on UMA Resource Sevrer
136
208
  ```ruby
137
209
  @uma_command.uma_rs_check_access(path, http_method)
138
210
  ```
139
- You must first get RPT before calling this method.
140
211
 
141
212
  ### Get Requesting Party Token(RPT)
142
213
  To gain access to protected resources at the UMA resource server, you must first obtain RPT.
143
214
 
144
- ```ruby
145
- @uma_command.uma_rp_get_rpt(force_new)
146
- ```
215
+ **Method parameters:**
147
216
 
148
- ### Authorize RPT
149
- You must first call `uma_rp_get_rpt` and `uma_rs_check_access` methods before authorizing RPT. If you have already obtained the RPT, use `uma_rp_authorize_rpt` method provided by oxd-ruby library to authorize it.
217
+ - claim_token: (Optional)
218
+ - claim_token_format: (Optional)
219
+ - pct: (Optional)
220
+ - rpt: (Optional)
221
+ - scope: (Optional)
222
+ - state: (Optional) state that is returned from uma_rp_get_claims_gathering_url method
150
223
 
151
224
  ```ruby
152
- @uma_command.uma_rp_authorize_rpt
225
+ @uma_command.uma_rp_get_rpt
153
226
  ```
154
227
 
155
- ### Get Gluu Access Token(GAT)
156
- To obtain GAT(Gluu Access Token) call following method with scopes as parameter.
228
+ ### UMA RP - Get Claims-Gathering URL
229
+
230
+ **Method parameters:**
231
+
232
+ - claims_redirect_uri: (Required)
157
233
 
158
234
  ```ruby
159
- @uma_command.uma_rp_get_gat(scopes)
235
+ @uma_command.uma_rp_get_claims_gathering_url
160
236
  ```
161
237
 
162
238
  ## Logs
@@ -33,7 +33,8 @@ gem "twitter-bootstrap-rails"
33
33
  # Use Capistrano for deployment
34
34
  # gem 'capistrano-rails', group: :development
35
35
 
36
- gem 'oxd-ruby', '~> 0.1.8'
36
+ #gem 'oxd-ruby', '~> 0.1.9'
37
+ gem 'oxd-ruby', path: '/var/www/oxd-ruby-3.1.1'
37
38
 
38
39
  group :development, :test do
39
40
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
@@ -0,0 +1,197 @@
1
+ PATH
2
+ remote: /var/www/oxd-ruby-3.1.1
3
+ specs:
4
+ oxd-ruby (0.1.9)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.2.6)
10
+ actionpack (= 4.2.6)
11
+ actionview (= 4.2.6)
12
+ activejob (= 4.2.6)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ actionpack (4.2.6)
16
+ actionview (= 4.2.6)
17
+ activesupport (= 4.2.6)
18
+ rack (~> 1.6)
19
+ rack-test (~> 0.6.2)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
+ actionview (4.2.6)
23
+ activesupport (= 4.2.6)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ activejob (4.2.6)
29
+ activesupport (= 4.2.6)
30
+ globalid (>= 0.3.0)
31
+ activemodel (4.2.6)
32
+ activesupport (= 4.2.6)
33
+ builder (~> 3.1)
34
+ activerecord (4.2.6)
35
+ activemodel (= 4.2.6)
36
+ activesupport (= 4.2.6)
37
+ arel (~> 6.0)
38
+ activesupport (4.2.6)
39
+ i18n (~> 0.7)
40
+ json (~> 1.7, >= 1.7.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ arel (6.0.4)
45
+ binding_of_caller (0.7.2)
46
+ debug_inspector (>= 0.0.1)
47
+ builder (3.2.3)
48
+ byebug (9.1.0)
49
+ coffee-rails (4.1.1)
50
+ coffee-script (>= 2.2.0)
51
+ railties (>= 4.0.0, < 5.1.x)
52
+ coffee-script (2.4.1)
53
+ coffee-script-source
54
+ execjs
55
+ coffee-script-source (1.12.2)
56
+ commonjs (0.2.7)
57
+ concurrent-ruby (1.0.5)
58
+ crass (1.0.2)
59
+ debug_inspector (0.0.3)
60
+ erubis (2.7.0)
61
+ execjs (2.7.0)
62
+ ffi (1.9.18)
63
+ globalid (0.4.0)
64
+ activesupport (>= 4.2.0)
65
+ grease (0.3.1)
66
+ i18n (0.8.6)
67
+ jbuilder (2.7.0)
68
+ activesupport (>= 4.2.0)
69
+ multi_json (>= 1.2)
70
+ jquery-rails (4.3.1)
71
+ rails-dom-testing (>= 1, < 3)
72
+ railties (>= 4.2.0)
73
+ thor (>= 0.14, < 2.0)
74
+ json (1.8.6)
75
+ less (2.6.0)
76
+ commonjs (~> 0.2.7)
77
+ less-rails (3.0.0)
78
+ actionpack (>= 4.0)
79
+ grease
80
+ less (~> 2.6.0)
81
+ sprockets (> 2, < 4)
82
+ tilt
83
+ loofah (2.1.1)
84
+ crass (~> 1.0.2)
85
+ nokogiri (>= 1.5.9)
86
+ mail (2.6.6)
87
+ mime-types (>= 1.16, < 4)
88
+ mime-types (3.1)
89
+ mime-types-data (~> 3.2015)
90
+ mime-types-data (3.2016.0521)
91
+ mini_portile2 (2.3.0)
92
+ minitest (5.10.3)
93
+ multi_json (1.12.2)
94
+ nokogiri (1.8.1)
95
+ mini_portile2 (~> 2.3.0)
96
+ passenger (5.1.8)
97
+ rack
98
+ rake (>= 0.8.1)
99
+ rack (1.6.8)
100
+ rack-test (0.6.3)
101
+ rack (>= 1.0)
102
+ rails (4.2.6)
103
+ actionmailer (= 4.2.6)
104
+ actionpack (= 4.2.6)
105
+ actionview (= 4.2.6)
106
+ activejob (= 4.2.6)
107
+ activemodel (= 4.2.6)
108
+ activerecord (= 4.2.6)
109
+ activesupport (= 4.2.6)
110
+ bundler (>= 1.3.0, < 2.0)
111
+ railties (= 4.2.6)
112
+ sprockets-rails
113
+ rails-deprecated_sanitizer (1.0.3)
114
+ activesupport (>= 4.2.0.alpha)
115
+ rails-dom-testing (1.0.8)
116
+ activesupport (>= 4.2.0.beta, < 5.0)
117
+ nokogiri (~> 1.6)
118
+ rails-deprecated_sanitizer (>= 1.0.1)
119
+ rails-html-sanitizer (1.0.3)
120
+ loofah (~> 2.0)
121
+ railties (4.2.6)
122
+ actionpack (= 4.2.6)
123
+ activesupport (= 4.2.6)
124
+ rake (>= 0.8.7)
125
+ thor (>= 0.18.1, < 2.0)
126
+ rake (12.1.0)
127
+ rb-fsevent (0.10.2)
128
+ rb-inotify (0.9.10)
129
+ ffi (>= 0.5.0, < 2)
130
+ rdoc (4.3.0)
131
+ sass (3.5.2)
132
+ sass-listen (~> 4.0.0)
133
+ sass-listen (4.0.0)
134
+ rb-fsevent (~> 0.9, >= 0.9.4)
135
+ rb-inotify (~> 0.9, >= 0.9.7)
136
+ sass-rails (5.0.6)
137
+ railties (>= 4.0.0, < 6)
138
+ sass (~> 3.1)
139
+ sprockets (>= 2.8, < 4.0)
140
+ sprockets-rails (>= 2.0, < 4.0)
141
+ tilt (>= 1.1, < 3)
142
+ sdoc (0.4.2)
143
+ json (~> 1.7, >= 1.7.7)
144
+ rdoc (~> 4.0)
145
+ spring (2.0.2)
146
+ activesupport (>= 4.2)
147
+ sprockets (3.7.1)
148
+ concurrent-ruby (~> 1.0)
149
+ rack (> 1, < 3)
150
+ sprockets-rails (3.2.1)
151
+ actionpack (>= 4.0)
152
+ activesupport (>= 4.0)
153
+ sprockets (>= 3.0.0)
154
+ sqlite3 (1.3.13)
155
+ thor (0.20.0)
156
+ thread_safe (0.3.6)
157
+ tilt (2.0.8)
158
+ turbolinks (5.0.1)
159
+ turbolinks-source (~> 5)
160
+ turbolinks-source (5.0.3)
161
+ twitter-bootstrap-rails (3.2.2)
162
+ actionpack (>= 3.1)
163
+ execjs (>= 2.2.2, >= 2.2)
164
+ less-rails (>= 2.5.0)
165
+ railties (>= 3.1)
166
+ tzinfo (1.2.3)
167
+ thread_safe (~> 0.1)
168
+ uglifier (3.2.0)
169
+ execjs (>= 0.3.0, < 3)
170
+ web-console (2.3.0)
171
+ activemodel (>= 4.0)
172
+ binding_of_caller (>= 0.7.2)
173
+ railties (>= 4.0)
174
+ sprockets-rails (>= 2.0, < 4.0)
175
+
176
+ PLATFORMS
177
+ ruby
178
+
179
+ DEPENDENCIES
180
+ byebug
181
+ coffee-rails (~> 4.1.0)
182
+ jbuilder (~> 2.0)
183
+ jquery-rails
184
+ oxd-ruby!
185
+ passenger
186
+ rails (= 4.2.6)
187
+ sass-rails (~> 5.0)
188
+ sdoc (~> 0.4.0)
189
+ spring
190
+ sqlite3
191
+ turbolinks
192
+ twitter-bootstrap-rails
193
+ uglifier (>= 1.3.0)
194
+ web-console (~> 2.0)
195
+
196
+ BUNDLED WITH
197
+ 1.14.4