Class: Oxd::ClientOxdCommands
- Inherits:
-
OxdConnector
- Object
- OxdConnector
- Oxd::ClientOxdCommands
- Defined in:
- lib/oxd/client_oxd_commands.rb
Instance Method Summary collapse
-
#get_authorization_url(acr_values = [""]) ⇒ Object
Args: => acr_values (list): OPTIONAL list of acr values in the order of priority Returns: => The authorization url (string) that the user must access for authentication and authorization.
-
#get_logout_uri(access_token, state = nil, session_state = nil) ⇒ Object
> id_token_hint (string): REQUIRED (oxd server will use last used access token) => post_logout_redirect_uri (string): OPTIONAL URI for redirection, this uri would override the value given in the website-config => state (string): OPTIONAL website state => session_state (string): OPTIONAL session state Returns: => The URI (string) to which the user must be directed in order to perform the logout.
-
#get_tokens_by_code(code, scopes, state = nil) ⇒ Object
Args: => code (string): code obtained from the auth url callback => scopes (list): scopes authorized by the OP, from the url callback => state (string): state key obtained from the auth url callback Returns: => The access token (string) which should be passed to get the user information from the OP.
-
#get_user_info(access_token) ⇒ Object
> The user data claims (named tuple) that are returned by the OP.
-
#getOxdId ⇒ Object
> The oxd_id (mixed) of the registration of website.
-
#initialize ⇒ ClientOxdCommands
constructor
ClientOxdCommands initialization.
-
#register_site ⇒ Object
> The oxd_id (mixed) of the registration of website.
-
#update_site_registration ⇒ Object
This should be called after changing the values in the config file.
Methods inherited from OxdConnector
#getData, #getResponseData, #is_json?, #logger, #oxd_socket_request, #request, #validate_command
Constructor Details
#initialize ⇒ ClientOxdCommands
ClientOxdCommands initialization
10 11 12 |
# File 'lib/oxd/client_oxd_commands.rb', line 10 def initialize super end |
Instance Method Details
#get_authorization_url(acr_values = [""]) ⇒ Object
Args:
> acr_values (list): OPTIONAL list of acr values in the order of priority
Returns:
> The authorization url (string) that the user must access for authentication and authorization
54 55 56 57 58 59 60 61 62 |
# File 'lib/oxd/client_oxd_commands.rb', line 54 def (acr_values = [""]) @command = 'get_authorization_url' @params = { "oxd_id" => @configuration.oxd_id, "acr_values" => acr_values || @configuration.acr_values } request getResponseData['authorization_url'] end |
#get_logout_uri(access_token, state = nil, session_state = nil) ⇒ Object
> id_token_hint (string): REQUIRED (oxd server will use last used access token)
> post_logout_redirect_uri (string): OPTIONAL URI for redirection, this uri would override the value given in the website-config
> state (string): OPTIONAL website state
> session_state (string): OPTIONAL session state
Returns:
> The URI (string) to which the user must be directed in order to perform the logout
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/oxd/client_oxd_commands.rb', line 112 def get_logout_uri(access_token, state = nil, session_state = nil) @command = 'get_logout_uri' @params = { "oxd_id" => @configuration.oxd_id, "id_token_hint" => access_token, "post_logout_redirect_uri" => @configuration.post_logout_redirect_uri, "state" => state, "session_state" => session_state } request getResponseData['uri'] end |
#get_tokens_by_code(code, scopes, state = nil) ⇒ Object
Args:
> code (string): code obtained from the auth url callback
> scopes (list): scopes authorized by the OP, from the url callback
> state (string): state key obtained from the auth url callback
Returns:
> The access token (string) which should be passed to get the user information from the OP
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/oxd/client_oxd_commands.rb', line 71 def get_tokens_by_code( code, scopes, state = nil) if (code.empty? || scopes.empty? || (!scopes.kind_of? Array)) logger(:log_msg => "Empty/Wrong value in place of code or scope.") end @command = 'get_tokens_by_code' @params = { "oxd_id" => @configuration.oxd_id, "code" => code, "scopes" => scopes, "state" => state } request getResponseData['access_token'] end |
#get_user_info(access_token) ⇒ Object
> The user data claims (named tuple) that are returned by the OP
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/oxd/client_oxd_commands.rb', line 91 def get_user_info(access_token) if access_token.empty? logger(:log_msg => "Empty access code sent for get_user_info", :error => "Empty access code") end @command = 'get_user_info' @params = { "oxd_id" => @configuration.oxd_id, "access_token" => access_token } request getResponseData['claims'] end |
#getOxdId ⇒ Object
> The oxd_id (mixed) of the registration of website
45 46 47 |
# File 'lib/oxd/client_oxd_commands.rb', line 45 def getOxdId return @configuration.oxd_id end |
#register_site ⇒ Object
> The oxd_id (mixed) of the registration of website
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/oxd/client_oxd_commands.rb', line 17 def register_site if(!@configuration.oxd_id.empty?) # Check if client is already registered return @configuration.oxd_id else @command = 'register_site' @configuration.scope = [ "openid", "profile","email"] @params = { "authorization_redirect_uri" => @configuration., "post_logout_redirect_uri" => @configuration.post_logout_redirect_uri, "application_type" => @configuration.application_type, "redirect_uris" => @configuration.redirect_uris, "acr_values" => @configuration.acr_values, "scope" => @configuration.scope, "client_jwks_uri" => @configuration.client_jwks_uri, "client_token_endpoint_auth_method" => @configuration.client_token_endpoint_auth_method, "client_request_uris" => @configuration.client_request_uris, "contacts" => @configuration.contacts, "grant_types" => @configuration.grant_types, "response_types"=> @configuration.response_types, "client_logout_uris"=> @configuration.client_logout_uris } request @configuration.oxd_id = getResponseData['oxd_id'] end end |
#update_site_registration ⇒ Object
This should be called after changing the values in the config file. Returns:
> The status (boolean) for update of information was sucessful or not
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/oxd/client_oxd_commands.rb', line 129 def update_site_registration @command = 'update_site_registration' @params = { "authorization_redirect_uri" => @configuration., "oxd_id" => @configuration.oxd_id, "post_logout_redirect_uri" => @configuration.post_logout_redirect_uri, "application_type" => @configuration.application_type, "redirect_uris" => @configuration.redirect_uris, "acr_values" => @configuration.acr_values, "scope" => @configuration.scope, "client_jwks_uri" => @configuration.client_jwks_uri, "client_token_endpoint_auth_method" => @configuration.client_token_endpoint_auth_method, "client_request_uris" => @configuration.client_request_uris, "contacts" => @configuration.contacts, "grant_types" => @configuration.grant_types, "response_types"=> @configuration.response_types, "client_logout_uris"=> @configuration.client_logout_uris } request if @response_object['status'] == "ok" @configuration.oxd_id = getResponseData['oxd_id'] return true else return false end end |