Class: LogtoClient::Config
- Inherits:
-
Object
- Object
- LogtoClient::Config
- Defined in:
- lib/logto/client/index_types.rb
Overview
The configuration object for the Logto client.
Instance Attribute Summary collapse
-
#app_id ⇒ String
The client ID of your application, you can get it from the integration guide or the application details page of the Logto Console.
-
#app_secret ⇒ String
The client secret of your application, you can get it from the application details page of the Logto Console.
-
#endpoint ⇒ URI
The endpoint for the Logto server, you can get it from the integration guide or the team settings page of the Logto Console.
-
#prompt ⇒ Array<String>
The prompt parameter to be used for the authorization request.
-
#resources ⇒ Array<String>
The API resources that your application needs to access.
-
#scopes ⇒ Array<String>
The scopes (permissions) that your application needs to access.
Instance Method Summary collapse
-
#initialize(endpoint:, app_id:, app_secret:, scopes: [], resources: [], prompt: , include_reserved_scopes: true) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(endpoint:, app_id:, app_secret:, scopes: [], resources: [], prompt: , include_reserved_scopes: true) ⇒ Config
Returns a new instance of Config.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/logto/client/index_types.rb', line 36 def initialize(endpoint:, app_id:, app_secret:, scopes: [], resources: [], prompt: LogtoCore::PROMPT[:consent], include_reserved_scopes: true) raise ArgumentError, "Scopes must be an array" if scopes && !scopes.is_a?(Array) raise ArgumentError, "Resources must be an array" if resources && !resources.is_a?(Array) raise ArgumentError, "Endpoint must not be empty" if endpoint.nil? || endpoint == "" computed_scopes = include_reserved_scopes ? LogtoUtils.with_reserved_scopes(scopes) : scopes @endpoint = endpoint.is_a?(URI) ? endpoint : URI.parse(endpoint) @app_id = app_id @app_secret = app_secret @scopes = computed_scopes @resources = computed_scopes.include?(LogtoCore::USER_SCOPE[:organizations]) ? ([LogtoCore::RESERVED_RESOURCE[:organization]] + resources).uniq : resources @prompt = prompt.is_a?(Array) ? prompt : [prompt] end |
Instance Attribute Details
#app_id ⇒ String
The client ID of your application, you can get it from the integration guide or the application details page of the Logto Console.
26 27 28 |
# File 'lib/logto/client/index_types.rb', line 26 def app_id @app_id end |
#app_secret ⇒ String
The client secret of your application, you can get it from the application details page of the Logto Console.
26 27 28 |
# File 'lib/logto/client/index_types.rb', line 26 def app_secret @app_secret end |
#endpoint ⇒ URI
The endpoint for the Logto server, you can get it from the integration guide or the team settings page of the Logto Console.
26 27 28 |
# File 'lib/logto/client/index_types.rb', line 26 def endpoint @endpoint end |
#prompt ⇒ Array<String>
The prompt parameter to be used for the authorization request.
26 27 28 |
# File 'lib/logto/client/index_types.rb', line 26 def prompt @prompt end |
#resources ⇒ Array<String>
The API resources that your application needs to access. You can specify multiple resources by providing an array of strings.
See RBAC to learn more about how to use role-based access control (RBAC) to protect API resources.
26 27 28 |
# File 'lib/logto/client/index_types.rb', line 26 def resources @resources end |
#scopes ⇒ Array<String>
The scopes (permissions) that your application needs to access. Scopes that will be added by default: ‘openid`, `offline_access` and `profile`. If resources are specified, scopes will be applied to every resource.
See Scopes and claims for more information of available scopes for user information.
26 27 28 |
# File 'lib/logto/client/index_types.rb', line 26 def scopes @scopes end |