oxd-ruby 0.1.8 → 0.1.9

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.
@@ -7,9 +7,40 @@ class ApplicationController < ActionController::Base
7
7
  protect_from_forgery with: :exception
8
8
 
9
9
  before_filter :set_oxd_commands_instance
10
+
11
+ # method to set the client attributes taken from user
12
+ # It should be called before adding, updating and deleting client settings
13
+ def set_oxd_config_values(op_host, authorization_redirect_uri, post_logout_redirect_uri, client_name, connection_type, connection_type_value, client_id, client_secret)
14
+ @oxdConfig.op_host = op_host if(!op_host.nil?)
15
+ @oxdConfig.authorization_redirect_uri = authorization_redirect_uri if(!op_host.nil?)
16
+ @oxdConfig.post_logout_redirect_uri = post_logout_redirect_uri if(!post_logout_redirect_uri.nil?)
17
+ @oxdConfig.client_name = client_name if(!client_name.nil?)
18
+ @oxdConfig.connection_type = connection_type if(!connection_type.nil?)
19
+ @oxdConfig.oxd_host = connection_type_value if(!connection_type_value.nil?)
20
+ @oxdConfig.client_id = client_id if(!client_id.nil?)
21
+ @oxdConfig.client_secret = client_secret if(!client_secret.nil?)
22
+ end
23
+
24
+ # @return [Boolean] type for openID Provider type, True for dynamic and False for static openID provider
25
+ # method to know static or dynamic openID Provider
26
+ # This should be called after getting the URI of the OpenID Provider, Client Redirect URI, Post logout URI, oxd port values from user
27
+ def check_openid_type(op_host)
28
+ op_host = op_host+"/.well-known/openid-configuration"
29
+ uri = URI.parse(op_host)
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ http.use_ssl = true
32
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
33
+ request = Net::HTTP::Get.new(uri.request_uri)
34
+ response = http.request(request)
35
+ ophost_data = response.body
36
+ @oxdConfig.dynamic_registration = (!JSON.parse(ophost_data).key?("registration_endpoint"))? false : true
37
+ @oxdConfig.scope = ["openid", "profile", "email"] if(@oxdConfig.dynamic_registration == false)
38
+ end
39
+
10
40
  protected
11
41
  def set_oxd_commands_instance
12
42
  @oxd_command = Oxd::ClientOxdCommands.new
13
43
  @uma_command = Oxd::UMACommands.new
14
- end
44
+ @oxdConfig = @oxd_command.oxdConfig
45
+ end
15
46
  end
@@ -1,24 +1,47 @@
1
1
  class HomeController < ApplicationController
2
- skip_before_filter :verify_authenticity_token
2
+ skip_before_filter :verify_authenticity_token
3
3
 
4
- def index
4
+ def index
5
+ end
6
+
7
+ def setup_client
8
+ unless(@oxdConfig.oxd_id.present?)
9
+ check_openid_type(@oxdConfig.op_host)
10
+
11
+ if(@oxdConfig.dynamic_registration == false && (@oxdConfig.client_id.nil? && @oxdConfig.client_secret.nil?))
12
+ flash[:info] = 'Enter client ID and client Secret in oxd_config.rb file'
13
+ else
14
+ @oxd_command.setup_client
15
+ end
16
+ end
17
+ flash[:success] = 'Client is registered with Oxd ID : '+@oxdConfig.oxd_id
18
+ redirect_to root_path
19
+ end
20
+
21
+ def get_client_token
22
+ @oxd_command.get_client_token # Fetch protection_access_token
23
+ redirect_to root_path
5
24
  end
6
25
 
7
26
  def register_site
8
- if(!@oxd_command.getOxdId.present?)
27
+ if(!@oxdConfig.oxd_id.present?)
9
28
  @oxd_command.register_site # Register site and store the returned oxd_id in config
10
- end
11
- authorization_url = @oxd_command.get_authorization_url
29
+ end
30
+ authorization_url = @oxd_command.get_authorization_url([],[], {"param1" => "value1","param2" => "value2"})
12
31
  redirect_to authorization_url # redirect user to obtained authorization_url to authenticate
13
32
  end
14
33
 
15
34
  def login
16
- if(@oxd_command.getOxdId.present?)
35
+ if(@oxdConfig.oxd_id.present?)
17
36
  if (params[:code].present?)
18
37
  # pass the parameters obtained from callback url to get access_token
19
38
  @access_token = @oxd_command.get_tokens_by_code( params[:code], params[:state])
20
39
  end
21
40
  session.delete('oxd_access_token') if(session[:oxd_access_token].present?)
41
+
42
+ if(@oxdConfig.dynamic_registration == true)
43
+ @access_token = @oxd_command.get_access_token_by_refresh_token
44
+ end
22
45
  session[:oxd_access_token] = @access_token
23
46
  session[:state] = params[:state]
24
47
  session[:session_state] = params[:session_state]
@@ -27,6 +50,16 @@ class HomeController < ApplicationController
27
50
  end
28
51
  end
29
52
 
53
+ def update_registration
54
+ @oxdConfig.client_name = "ClienName 2"
55
+ if(@oxd_command.update_site_registration)
56
+ flash[:success] = 'Client settings are updated successfully!!'
57
+ else
58
+ flash[:error] = 'There was some error in updating Client settings'
59
+ end
60
+ redirect_to root_path
61
+ end
62
+
30
63
  def logout
31
64
  # get logout url and redirect user that URL to logout from OP
32
65
  if(session[:oxd_access_token])
@@ -34,4 +67,13 @@ class HomeController < ApplicationController
34
67
  redirect_to @logout_url
35
68
  end
36
69
  end
70
+
71
+ def clear_data
72
+ @oxdConfig.oxd_id = ""
73
+ @oxdConfig.client_id = "";
74
+ @oxdConfig.client_secret = "";
75
+ @oxdConfig.client_name = "";
76
+ @oxdConfig.protection_access_token = "";
77
+ redirect_to root_path
78
+ end
37
79
  end
@@ -2,24 +2,30 @@ class UmaController < ApplicationController
2
2
  skip_before_filter :verify_authenticity_token
3
3
  require 'json'
4
4
 
5
- def index
5
+ def index
6
+ end
7
+
8
+ def get_client_token
9
+ @oxd_command.get_client_token
10
+ redirect_to uma_index_path
6
11
  end
7
12
 
8
13
  def protect_resources
9
- condition1_for_path1 = {:httpMethods => ["GET"], :scopes => ["http://photoz.example.com/dev/actions/view"]}
10
- condition2_for_path1 = {:httpMethods => ["PUT", "POST"], :scopes => ["http://photoz.example.com/dev/actions/all","http://photoz.example.com/dev/actions/add"], :ticketScopes => ["http://photoz.example.com/dev/actions/add"]}
14
+ condition1_for_path1 = {:httpMethods => ["GET"], :scopes => ["https://scim-test.gluu.org/identity/seam/resource/restv1/scim/vas1/view"]}
15
+ condition2_for_path1 = {:httpMethods => ["PUT", "POST"], :scopes => ["https://scim-test.gluu.org/identity/seam/resource/restv1/scim/vas1/all","https://scim-test.gluu.org/identity/seam/resource/restv1/scim/vas1/add"], :ticketScopes => ["https://scim-test.gluu.org/identity/seam/resource/restv1/scim/vas1/add"]}
11
16
 
12
- condition1_for_path2 = {:httpMethods => ["GET"], :scopes => ["http://photoz.example.com/dev/actions/view"]}
17
+ condition1_for_path2 = {:httpMethods => ["GET"], :scopes => ["https://scim-test.gluu.org/identity/seam/resource/restv1/scim/vas1/all"]}
13
18
 
14
19
  @uma_command.uma_add_resource("/photo", condition1_for_path1, condition2_for_path1) # Add Resource#1
15
20
  @uma_command.uma_add_resource("/document", condition1_for_path2) # Add Resource#2
21
+
16
22
  response = @uma_command.uma_rs_protect # Register above resources with UMA RS
17
23
  render :template => "uma/index", :locals => { :protect_resources_response => response }
18
24
  end
19
25
 
20
26
  def get_rpt
21
- rpt = @uma_command.uma_rp_get_rpt('false') # Get RPT
22
- render :template => "uma/index", :locals => { :rpt => rpt }
27
+ response = @uma_command.uma_rp_get_rpt
28
+ render :template => "uma/index", :locals => { :get_rpt_response => response }
23
29
  end
24
30
 
25
31
  def check_access
@@ -27,14 +33,8 @@ class UmaController < ApplicationController
27
33
  render :template => "uma/index", :locals => { :check_access_response => response }
28
34
  end
29
35
 
30
- def authorize_rpt
31
- response = @uma_command.uma_rp_authorize_rpt # Authorize RPT
32
- render :template => "uma/index", :locals => { :authorize_rpt_response => response }
36
+ def get_claims_gathering_url
37
+ response = @uma_command.uma_rp_get_claims_gathering_url('/photo')
38
+ render :template => "uma/index", :locals => { :get_claims_gathering_url_response => response }
33
39
  end
34
-
35
- def get_gat
36
- scopes = ["http://photoz.example.com/dev/actions/add","http://photoz.example.com/dev/actions/view","http://photoz.example.com/dev/actions/edit"]
37
- gat = @uma_command.uma_rp_get_gat(scopes) # Pass scopes array to get GAT
38
- render :template => "uma/index", :locals => { :gat => gat }
39
- end
40
40
  end
@@ -2,48 +2,70 @@
2
2
  <h2>Ruby on Rails demo Site for OxD Ruby Library</h2>
3
3
  <p>This is a demo site showcasing the usage of OxD Ruby Library. The demo site is written in Ruby on Rails and shows that the library can be used to perform OpenID based authentication.</p>
4
4
  </div>
5
+
6
+ <% flash.each do |key, value| %>
7
+ <div class="alert alert-<%= key %>"><%= value %></div>
8
+ <% end %>
9
+
5
10
  <div class="row">
6
11
  <div class="col-md-6">
7
- <h3>Configuration File</h3>
8
- <p>Website specific configuration information is stored in a config file. This is necessary for storing persistant information like Oxd ID generated during the site registration with the Open ID provider.
9
- The <code>oxd_config.rb</code> shows the config file used for this demo app. The complete documentation about the config file can be obtained <a href="https://github.com/GluuFederation/oxd-ruby">here in Github</a>
10
- </p>
12
+ <h3>Setup Client</h3>
13
+ <p>
14
+ 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 <code>get_client_token</code> method. The Setup Client method is a one time task to configure a client in the oxd server and OP.
15
+ </p>
16
+ <b>Note:</b> 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 <code>oxd_config.rb</code> initializer file.
17
+ <hr>
18
+ <% if @oxdConfig.oxd_id.present? %>
19
+ <div class="alert alert-success">
20
+ Client is registered with Oxd ID : <%= @oxdConfig.oxd_id %>
21
+ </div>
22
+ <p><strong> Clear Saved Client configuration - </strong><a class="btn btn-primary" href="<%= clear_data_path %>" >Clear data</a></p>
23
+ <% else %>
24
+ <p><strong> Live demo - </strong><a class="btn btn-primary" href="<%= setup_client_path %>" >Setup Client</a></p>
25
+ <% end %>
11
26
  </div>
12
27
  <div class="col-md-6">
13
- <h3>oxd_config.rb</h3>
14
- <pre class="prettyprint">
15
- Oxd.configure do |config|
16
- config.oxd_host_ip = '127.0.0.1'
17
- config.oxd_host_port = 8099
18
- config.op_host = "https://ce-dev2.gluu.org"
19
- config.authorization_redirect_uri = "https://oxd-rails.com/login"
20
- config.logout_redirect_uri = "https://oxd-rails.com/logout"
21
- config.post_logout_redirect_uri = "https://oxd-rails.com/"
22
- config.scope = [ "openid", "profile" ]
23
- config.application_type = "web"
24
- config.client_jwks_uri = ""
25
- config.client_token_endpoint_auth_method = ""
26
- config.client_request_uris = []
27
- config.contacts = ["example-email@gmail.com"]
28
- config.grant_types = []
29
- config.response_types = ["code"]
30
- config.acr_values = ["basic"]
31
- config.client_logout_uris = ['https://oxd-rails.com/logout']
28
+ <pre class="prettyprint">
29
+ def setup_client
30
+ unless(@oxdConfig.oxd_id.present?)
31
+ check_openid_type(@oxdConfig.op_host)
32
+
33
+ if(@oxdConfig.dynamic_registration == false && (@oxdConfig.client_id.nil? && @oxdConfig.client_secret.nil?))
34
+ flash[:info] = 'Enter client ID and client Secret in oxd_config.rb file'
35
+ else
36
+ @oxd_command.setup_client
37
+ end
38
+ end
39
+ flash[:success] = 'Client is registered with Oxd ID : '+@oxdConfig.oxd_id
40
+ redirect_to root_path
32
41
  end
33
- </pre>
42
+ </pre>
34
43
  </div>
35
44
  </div>
36
45
  <div class="row">
37
46
  <div class="col-md-6">
38
- <h3>Registration and Fetching Auth URL</h3>
39
- <p>The first step is to register the client with the OP. Once the client is registered, then the user data can be fetched upon user authorization.
40
- oxD Ruby performs client registration automatically when you request for an authorization url. Redirect the user to the authorization url to get user
41
- consent.</p>
47
+ <h3>Get Client Token and Login to Open Id</h3>
48
+ <p>Once the client is registered, then the user data can be fetched upon user authorization. <code>get_client_token</code> command must be invoked to use all other methods of API when the <code>protect_commands_with_access_token</code> is enabled in oxd-server.
49
+ oxD Ruby performs client registration automatically when you request for an authorization url. Redirect the user to the authorization url to get user consent.</p>
42
50
  <hr>
43
- <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= register_site_path %>">Go to Authorization Page</a></p>
51
+ <% if @oxdConfig.oxd_id.present? %>
52
+ <% if @oxdConfig.protection_access_token.present? %>
53
+ <div class="alert alert-success">
54
+ Obtained protection access token is : <%= @oxdConfig.protection_access_token %>
55
+ </div>
56
+ <p><strong>Login with Open ID Live demo - </strong><a class="btn btn-primary" href="<%= register_site_path %>" >Login with Open ID</a></p>
57
+ <% else %>
58
+ <p><strong>Get Client Token Live demo - </strong><a class="btn btn-primary" href="<%= get_client_token_path %>" >Get Client Token</a></p>
59
+ <% end %>
60
+ <% end %>
44
61
  </div>
45
62
  <div class="col-md-6">
46
63
  <pre class="prettyprint">
64
+ def get_client_token
65
+ @oxd_command.get_client_token
66
+ redirect_to root_path
67
+ end
68
+
47
69
  def register_site
48
70
  if(!@oxd_command.getOxdId.present?)
49
71
  @oxd_command.register_site
@@ -57,22 +79,27 @@ end
57
79
  <div class="row">
58
80
  <div class="col-md-6">
59
81
  <h3>Get user information</h3>
60
- <p>Once the user authorizes the website to use the information from the OP, the OP calls back the website with code and scopes for accessing the user data in the registered callback <code>authorization_redirect_uri</code> in the config file. Then an access token is obtained from the OP using which user claims can be requested.</p>
82
+ <p>Once the user authorizes the website to use the information from the OP, the OP calls back the website with code and scopes for accessing the user data in the registered callback <code>authorization_redirect_uri</code> in the config file. Then an access token is obtained from the OP using <code>get_tokens_by_code</code> command with which user claims can be requested.</p>
83
+ <p>The <code>get_access_token_by_refresh_token</code> method can be used to get a fresh access token and refresh token by using the refresh token which is obtained from <code>get_tokens_by_code</code> method. The newly obtained access token can be used with <code>get_user_info</code> command to fetch user claims.
84
+ </p>
61
85
  </div>
62
86
  <div class="col-md-6">
63
87
  <pre class="prettyprint">
64
88
  def login
65
- if(@oxd_command.getOxdId.present?)
89
+ if(@oxdConfig.oxd_id.present?)
66
90
  if (params[:code].present?)
67
- @access_token = @oxd_command.get_tokens_by_code( params[:code],params[:state])
91
+ @access_token = @oxd_command.get_tokens_by_code( params[:code], params[:state])
68
92
  end
69
93
  session.delete('oxd_access_token') if(session[:oxd_access_token].present?)
94
+ if(@oxdConfig.dynamic_registration == true)
95
+ @access_token = @oxd_command.get_access_token_by_refresh_token
96
+ end
70
97
  session[:oxd_access_token] = @access_token
71
98
  session[:state] = params[:state]
72
99
  session[:session_state] = params[:session_state]
73
- @user = @oxd_command.get_user_info(session[:oxd_access_token])
74
- render :template => "home/index", :locals => { :user => @user }
75
- end
100
+ @user = @oxd_command.get_user_info(session[:oxd_access_token]) # pass access_token get user information from OP
101
+ render :template => "home/index", :locals => { :user => @user }
102
+ end
76
103
  end
77
104
  </pre>
78
105
  </div>
@@ -106,11 +133,39 @@ end
106
133
  </pre>
107
134
  </div>
108
135
  </div>
136
+ <div class="row">
137
+ <div class="col-md-6">
138
+ <h3>Update webiste registration</h3>
139
+ <p>The <code>update_site_registration</code> method can be used to update an existing client in the OpenID Connect Provider (OP). Fields like Authorization Redirect URL, Post Logout URL, Scope, Client Secret and other fields can be updated using this method.</p>
140
+ <% if(@oxdConfig.oxd_id.present? && @oxdConfig.protection_access_token.present?) %>
141
+ <p><strong>Update webiste registration Live demo. </strong><a class="btn btn-primary" href="<%= update_registration_path %>">Update</a></p>
142
+ <% else %>
143
+ <div class="alert alert-warning">No business card for you. Obtain OxdID and Protection Access Token first</div>
144
+ <% end %>
145
+ </div>
146
+ <div class="col-md-6">
147
+ <pre class="prettyprint">
148
+ def update_registration
149
+ @oxdConfig.client_name = "ClienName 2"
150
+ if(@oxd_command.update_site_registration)
151
+ flash[:success] = 'Client settings are updated successfully!!'
152
+ else
153
+ flash[:error] = 'There was some error in updating Client settings'
154
+ end
155
+ redirect_to root_path
156
+ end
157
+ </pre>
158
+ </div>
159
+ </div>
109
160
  <div class="row">
110
161
  <div class="col-md-6">
111
162
  <h3>UMA Demo</h3>
112
163
  <p>UMA defines how resource owners can control protected-resource access by clients operated by arbitrary requesting parties.Once the website has been registered and authorized with OP you can register protection document with UMA.</p>
113
- <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= uma_index_path %>" target="_blank">Go to UMA demo page</a></p>
164
+ <% if(@oxdConfig.oxd_id.present? && @oxdConfig.protection_access_token.present?) %>
165
+ <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= uma_index_path %>" target="_blank">Go to UMA demo page</a></p>
166
+ <% else %>
167
+ <div class="alert alert-warning">No business card for you. Obtain OxdID and Protection Access Token first</div>
168
+ <% end %>
114
169
  </div>
115
170
  </div>
116
171
  <div class="row">
@@ -129,4 +184,27 @@ def logout
129
184
  end
130
185
  </pre>
131
186
  </div>
132
- </div>
187
+ </div>
188
+
189
+ <script type="text/javascript">
190
+ $(document).ready(function() {
191
+
192
+ <% if @oxdConfig.oxd_id.present? %>
193
+ $('.disabled').attr('disabled',true);
194
+ <% if @oxdConfig.dynamic_registration == true %>
195
+ $('.dynamic_registration_disabled').attr('disabled',true);
196
+ <% end %>
197
+ <% end %>
198
+
199
+ $('input[name=connection_type]').on('change', function(){
200
+ var checked_btn = $(this).val();
201
+ $('.connection_type_value').addClass('hidden');
202
+ $('.'+checked_btn+'_connection_type').removeClass('hidden');
203
+ });
204
+
205
+ $('#login').on('click', function(evt){
206
+ evt.preventDefault();
207
+ window.location = '<%= register_site_path %>';
208
+ });
209
+ });
210
+ </script>
@@ -1,7 +1,25 @@
1
1
  <div class="jumbotron">
2
2
  <h2>UMA RS and UMA RP Demo page for OxD Ruby Library</h2>
3
3
  </div>
4
-
4
+ <div class="row">
5
+ <div class="col-md-6">
6
+ <h3>Get Client Token</h3>
7
+ <p><code>get_client_token</code> command must be invoked to use all other methods of API when the <code>protect_commands_with_access_token</code> is enabled in oxd-server.</p>
8
+ <hr>
9
+ <div class="alert alert-success">
10
+ Obtained protection access token is : <%= @oxdConfig.protection_access_token %>
11
+ </div>
12
+ <p><strong>Get Client Token Live demo - </strong><a class="btn btn-primary" href="<%= get_client_token_uma_index_path %>" >Get Client Token</a></p>
13
+ </div>
14
+ <div class="col-md-6">
15
+ <pre class="prettyprint">
16
+ def get_client_token
17
+ @oxd_command.get_client_token
18
+ redirect_to uma_index_path
19
+ end
20
+ </pre>
21
+ </div>
22
+ </div>
5
23
  <div class="row">
6
24
  <div class="col-md-6">
7
25
  <h3>UMA RS Protect resources</h3>
@@ -31,19 +49,19 @@ end
31
49
  <div class="row">
32
50
  <div class="col-md-6">
33
51
  <h3>UMA RP - Get RPT</h3>
34
- <p>To gain access to protected resources at the UMA resource server, you must first obtain RPT (Requesting Party Token) using <code>uma_rp_get_rpt(force_new)</code> call.</p>
52
+ <p>To gain access to protected resources at the UMA resource server, you must first obtain RPT (Requesting Party Token) using <code>uma_rp_get_rpt</code> call.</p>
35
53
  <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= get_rpt_uma_index_path %>">Get RPT</a></p>
36
- <% if defined?(rpt) %>
54
+ <% if defined?(get_rpt_response) %>
37
55
  <div class="alert alert-success">
38
- <%= "Response RPT is: #{rpt}" %>
56
+ <%= "Response is: #{get_rpt_response}" %>
39
57
  </div>
40
58
  <% end %>
41
59
  </div>
42
60
  <div class="col-md-6">
43
61
  <pre class="prettyprint">
44
62
  def get_rpt
45
- rpt = @uma_command.uma_rp_get_rpt(false)
46
- render :template => "uma/index", :locals => { :rpt => rpt }
63
+ response = @uma_command.uma_rp_get_rpt
64
+ render :template => "uma/index", :locals => { :get_rpt_response => response }
47
65
  end
48
66
  </pre>
49
67
  </div>
@@ -76,46 +94,30 @@ end
76
94
  </pre>
77
95
  </div>
78
96
  </div>
79
- <hr>
80
97
  <div class="row">
81
98
  <div class="col-md-6">
82
- <h3>UMA RP - Authorize RPT</h3>
83
- <p>You must first get RPT (refer to 'Get RPT' section) before authorizing. If you have already obtained the RPT, use <code>uma_rp_authorize_rpt</code> method provided by oxd-ruby library to authorize RPT.</p>
84
- <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= authorize_rpt_uma_index_path %>">Authorize RPT</a></p>
85
- <% if defined?(authorize_rpt_response) %>
86
- <div class="alert alert-success">
87
- <%= "Response Oxd ID: #{authorize_rpt_response}" %>
88
- </div>
89
- <% end %>
99
+ <h3>UMA RP - Get Claims-Gathering URL</h3>
100
+ <p>After being redirected to the Claims Gathering URL the user goes through the claims gathering flow. If successful, the user is redirected back to claims_redirect_uri with a new ticket</p>
101
+ <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= get_claims_gathering_url_uma_index_path %>">Get Claims-Gathering URL</a></p>
102
+ <% if defined?(get_claims_gathering_url_response) %>
103
+ <% if get_claims_gathering_url_response['access'] == 'denied' %>
104
+ <div class="alert alert-warning">
105
+ <%= "Response : access #{get_claims_gathering_url_response['access']}" %><br>
106
+ <%= "Response ticket : #{get_claims_gathering_url_response['ticket']}" if get_claims_gathering_url_response['ticket'].present? %>
107
+ </div>
108
+ <% else %>
109
+ <div class="alert alert-success">
110
+ <%= "Response : #{get_claims_gathering_url_response}" %>
111
+ </div>
112
+ <% end %>
113
+ <% end %>
90
114
  </div>
91
115
  <div class="col-md-6">
92
116
  <pre class="prettyprint">
93
- def authorize_rpt
94
- response = @uma_command.uma_rp_authorize_rpt
95
- render :template => "uma/index", :locals => { :authorize_rpt_response => response }
117
+ def get_claims_gathering_url
118
+ response = @uma_command.uma_rp_get_claims_gathering_url('/photo')
119
+ render :template => "uma/index", :locals => { :get_claims_gathering_url_response => response }
96
120
  end
97
121
  </pre>
98
122
  </div>
99
- </div>
100
- <hr>
101
- <div class="row">
102
- <div class="col-md-6">
103
- <h3>UMA RP - Get GAT</h3>
104
- <p>To obtain GAT(Gluu Access Token) call to <code>uma_rp_get_gat(scopes)</code> method with scopes as parameter.</p>
105
- <p><strong> Live demo. </strong><a class="btn btn-primary" href="<%= get_gat_uma_index_path %>">Get GAT</a></p>
106
- <% if defined?(gat) %>
107
- <div class="alert alert-success">
108
- <%= "Response GAT is: #{gat}" %>
109
- </div>
110
- <% end %>
111
- </div>
112
- <div class="col-md-6">
113
- <pre class="prettyprint">
114
- def get_gat
115
- scopes = ["http://photoz.example.com/dev/actions/add","http://photoz.example.com/dev/actions/view","http://photoz.example.com/dev/actions/edit"]
116
- gat = @uma_command.uma_rp_get_gat(scopes)
117
- render :template => "uma/index", :locals => { :gat => gat }
118
- end
119
- </pre>
120
- </div>
121
123
  </div>