Module: Dina::Authentication
- Defined in:
- lib/dina/authentication/authentication.rb
Class Attribute Summary collapse
-
.authorization_url ⇒ Object
Returns the value of attribute authorization_url.
-
.client_id ⇒ Object
Returns the value of attribute client_id.
-
.endpoint_url ⇒ Object
Returns the value of attribute endpoint_url.
-
.realm ⇒ Object
Returns the value of attribute realm.
-
.server_name ⇒ Object
Returns the value of attribute server_name.
-
.token_store_file ⇒ Object
Returns the value of attribute token_store_file.
Class Method Summary collapse
-
.config(options = {}) ⇒ Object
Sets Authentication configuration Options hash as follows: { token_store_file: “file to store the token”, user: “username provided by DINA admin in Keycloak”, password: “password provided by DINA admin in Keycloak”, server_name: “used locally to reference the token”, client_id: “provided by DINA admin in Keycloak”, endpoint_url: “DINA API URL”, authorization_url: “Keycloak authorization URL”. realm: “provided by DINA admin in Keycloak” }.
-
.header ⇒ String
Gets, sets, and renews a Bearer access token as required and produces a Header string.
Class Attribute Details
.authorization_url ⇒ Object
Returns the value of attribute authorization_url.
50 51 52 |
# File 'lib/dina/authentication/authentication.rb', line 50 def @authorization_url end |
.client_id ⇒ Object
Returns the value of attribute client_id.
50 51 52 |
# File 'lib/dina/authentication/authentication.rb', line 50 def client_id @client_id end |
.endpoint_url ⇒ Object
Returns the value of attribute endpoint_url.
50 51 52 |
# File 'lib/dina/authentication/authentication.rb', line 50 def endpoint_url @endpoint_url end |
.realm ⇒ Object
Returns the value of attribute realm.
50 51 52 |
# File 'lib/dina/authentication/authentication.rb', line 50 def realm @realm end |
.server_name ⇒ Object
Returns the value of attribute server_name.
50 51 52 |
# File 'lib/dina/authentication/authentication.rb', line 50 def server_name @server_name end |
.token_store_file ⇒ Object
Returns the value of attribute token_store_file.
50 51 52 |
# File 'lib/dina/authentication/authentication.rb', line 50 def token_store_file @token_store_file end |
Class Method Details
.config(options = {}) ⇒ Object
Sets Authentication configuration Options hash as follows:
token_store_file: "file to store the token",
user: "username provided by DINA admin in Keycloak",
password: "password provided by DINA admin in Keycloak",
server_name: "used locally to reference the token",
client_id: "provided by DINA admin in Keycloak",
endpoint_url: "DINA API URL",
authorization_url: "Keycloak authorization URL".
realm: "provided by DINA admin in Keycloak"
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dina/authentication/authentication.rb', line 20 def self.config( = {}) @token_store_file = [:token_store_file] @user = [:user] @password = [:password] @server_name = [:server_name] @client_id = [:client_id] @endpoint_url = [:endpoint_url] @authorization_url = [:authorization_url] @realm = [:realm] Keycloak.auth_server_url = @authorization_url Keycloak.realm = @realm end |
.header ⇒ String
Gets, sets, and renews a Bearer access token as required and produces a Header string
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dina/authentication/authentication.rb', line 37 def self.header if access_token.nil? || refresh_token.nil? set_token end if Time.now >= Time.parse(auth_expiry) renew_token end "Bearer " + access_token end |