Class: TRMNLP::OAuth::Provider
- Inherits:
-
Object
- Object
- TRMNLP::OAuth::Provider
- Defined in:
- lib/trmnlp/oauth/provider.rb
Overview
Provider definition from the flat oauth_* keys in src/settings.yml (which round-trip through push/pull). Credentials stay local and env-first so they are never synced or committed.
Constant Summary collapse
- ENV_CLIENT_ID =
'TRMNL_OAUTH_CLIENT_ID'- ENV_CLIENT_SECRET =
'TRMNL_OAUTH_CLIENT_SECRET'
Instance Method Summary collapse
- #authorize_url ⇒ Object
- #client_id ⇒ Object
- #client_secret ⇒ Object
- #configured? ⇒ Boolean
- #enabled? ⇒ Boolean
-
#initialize(settings, env: ENV) ⇒ Provider
constructor
A new instance of Provider.
- #pkce? ⇒ Boolean
- #refresh_url ⇒ Object
- #scope_separator ⇒ Object
- #scopes ⇒ Object
- #token_url ⇒ Object
Constructor Details
#initialize(settings, env: ENV) ⇒ Provider
Returns a new instance of Provider.
12 13 14 15 |
# File 'lib/trmnlp/oauth/provider.rb', line 12 def initialize(settings, env: ENV) @settings = settings || {} @env = env end |
Instance Method Details
#authorize_url ⇒ Object
17 |
# File 'lib/trmnlp/oauth/provider.rb', line 17 def = settings['oauth_authorize_url'] |
#client_id ⇒ Object
24 |
# File 'lib/trmnlp/oauth/provider.rb', line 24 def client_id = env_first(ENV_CLIENT_ID, settings['oauth_client_id']) |
#client_secret ⇒ Object
25 |
# File 'lib/trmnlp/oauth/provider.rb', line 25 def client_secret = env_first(ENV_CLIENT_SECRET, settings['oauth_client_secret']) |
#configured? ⇒ Boolean
27 28 29 30 31 |
# File 'lib/trmnlp/oauth/provider.rb', line 27 def configured? return false unless enabled? && && token_url && client_id pkce? || present?(client_secret) end |
#enabled? ⇒ Boolean
23 |
# File 'lib/trmnlp/oauth/provider.rb', line 23 def enabled? = truthy?(settings['oauth_enabled']) |
#pkce? ⇒ Boolean
22 |
# File 'lib/trmnlp/oauth/provider.rb', line 22 def pkce? = truthy?(settings['oauth_pkce_enabled']) |
#refresh_url ⇒ Object
19 |
# File 'lib/trmnlp/oauth/provider.rb', line 19 def refresh_url = settings['oauth_refresh_url'] || token_url |
#scope_separator ⇒ Object
21 |
# File 'lib/trmnlp/oauth/provider.rb', line 21 def scope_separator = settings['oauth_scope_separator'] || ' ' |
#scopes ⇒ Object
20 |
# File 'lib/trmnlp/oauth/provider.rb', line 20 def scopes = settings['oauth_scopes'] |
#token_url ⇒ Object
18 |
# File 'lib/trmnlp/oauth/provider.rb', line 18 def token_url = settings['oauth_token_url'] |