Class: StandardConfig::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/standard_config/config.rb

Overview

Manages configuration for the StandardId engine

Usage:

StandardId.configure do |config|
  config. = "User"
  config.cache_store = ActiveSupport::Cache::MemoryStore.new
  config.logger = Rails.logger
  config.allowed_post_logout_redirect_uris = ["https://example.com/logout"]
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/standard_config/config.rb', line 45

def initialize
  @account_class_name = nil
  @cache_store = nil
  @logger = nil
  @issuer = nil
  @login_url = nil
  @google_client_id = nil
  @google_client_secret = nil
  @apple_client_id = nil
  @apple_client_secret = nil
  @apple_private_key = nil
  @apple_key_id = nil
  @apple_team_id = nil
  @social_account_attributes = nil
  @social_callback = nil
  @passwordless_email_sender = nil
  @passwordless_sms_sender = nil
  @allowed_post_logout_redirect_uris = []
  @web_layout = nil
end

Instance Attribute Details

#account_class_nameObject

The name of the Account model class as a String, e.g. “User” or “Account”



13
14
15
# File 'lib/standard_config/config.rb', line 13

def 
  @account_class_name
end

#allowed_post_logout_redirect_urisObject

Allowed post-logout redirect URIs for OIDC logout endpoint If empty or nil, no redirects are allowed and the endpoint will return a JSON message If provided, the post_logout_redirect_uri must exactly match one of the values in this list



38
39
40
# File 'lib/standard_config/config.rb', line 38

def allowed_post_logout_redirect_uris
  @allowed_post_logout_redirect_uris
end

#apple_client_idObject

Returns the value of attribute apple_client_id.



28
29
30
# File 'lib/standard_config/config.rb', line 28

def apple_client_id
  @apple_client_id
end

#apple_client_secretObject

Returns the value of attribute apple_client_secret.



28
29
30
# File 'lib/standard_config/config.rb', line 28

def apple_client_secret
  @apple_client_secret
end

#apple_key_idObject

Returns the value of attribute apple_key_id.



28
29
30
# File 'lib/standard_config/config.rb', line 28

def apple_key_id
  @apple_key_id
end

#apple_private_keyObject

Returns the value of attribute apple_private_key.



28
29
30
# File 'lib/standard_config/config.rb', line 28

def apple_private_key
  @apple_private_key
end

#apple_team_idObject

Returns the value of attribute apple_team_id.



28
29
30
# File 'lib/standard_config/config.rb', line 28

def apple_team_id
  @apple_team_id
end

#cache_storeObject

Optional cache store and logger, used by StandardId.cache_store and StandardId.logger



16
17
18
# File 'lib/standard_config/config.rb', line 16

def cache_store
  @cache_store
end

#google_client_idObject

Social login provider credentials and hooks



27
28
29
# File 'lib/standard_config/config.rb', line 27

def google_client_id
  @google_client_id
end

#google_client_secretObject

Social login provider credentials and hooks



27
28
29
# File 'lib/standard_config/config.rb', line 27

def google_client_secret
  @google_client_secret
end

#issuerObject

OAuth issuer identifier for ID tokens



19
20
21
# File 'lib/standard_config/config.rb', line 19

def issuer
  @issuer
end

#loggerObject

Optional cache store and logger, used by StandardId.cache_store and StandardId.logger



16
17
18
# File 'lib/standard_config/config.rb', line 16

def logger
  @logger
end

#login_urlObject

Optional login URL for redirecting unauthenticated browser requests Example: “/login” or a full URL like “app.example.com/login” If set, Authorization endpoints can redirect to this path with a redirect_uri param



24
25
26
# File 'lib/standard_config/config.rb', line 24

def 
  @login_url
end

#passwordless_email_senderObject

Passwordless authentication callbacks These should be callable objects (procs/lambdas) that accept (recipient, code) parameters



33
34
35
# File 'lib/standard_config/config.rb', line 33

def passwordless_email_sender
  @passwordless_email_sender
end

#passwordless_sms_senderObject

Passwordless authentication callbacks These should be callable objects (procs/lambdas) that accept (recipient, code) parameters



33
34
35
# File 'lib/standard_config/config.rb', line 33

def passwordless_sms_sender
  @passwordless_sms_sender
end

#social_account_attributesObject

Returns the value of attribute social_account_attributes.



29
30
31
# File 'lib/standard_config/config.rb', line 29

def 
  @social_account_attributes
end

#social_callbackObject

Returns the value of attribute social_callback.



29
30
31
# File 'lib/standard_config/config.rb', line 29

def social_callback
  @social_callback
end

#web_layoutObject

Layout name to use for StandardId Web controllers. If nil, controllers should default to “application” (host app or dummy app). Examples: “application”, “standard_id/web/application”, “my_custom_layout”



43
44
45
# File 'lib/standard_config/config.rb', line 43

def web_layout
  @web_layout
end

Instance Method Details

#account_classObject



66
67
68
69
70
# File 'lib/standard_config/config.rb', line 66

def 
  .constantize
rescue NameError
  raise NameError, "Could not find account class: #{}. Please set a valid class name using `StandardId.configure { |c| c.account_class_name = 'YourAccountClass' }`"
end