Class: OpenStax::Accounts::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax/accounts/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/openstax/accounts/configuration.rb', line 118

def initialize
  @openstax_application_id = 'SET ME!'
  @openstax_application_secret = 'SET ME!'
  @openstax_accounts_url = 'https://openstax.org/accounts'
  @enable_stubbing = true
  @logout_via = :get
  @default_errors_partial = 'openstax/accounts/shared/attention'
  @default_errors_html_id = 'openstax-accounts-attention'
  @default_errors_added_trigger = 'openstax-accounts-errors-added'
  @security_transgression_exception = SecurityTransgression
  @account_user_mapper = OpenStax::Accounts::DefaultAccountUserMapper
  @min_search_characters = 3
  @max_search_items = 10
  @logout_handler = nil
  @logout_redirect_url = nil
  @return_to_url_approver = nil
  @forwardable_login_params = [
    :signup_at,
    :go,
    sp: {} # "signed payload"; "sp" to keep nested parameter names short.
  ]
  @max_user_updates_per_request = 250
  @sso_cookie_name = 'ox'
  @sso_secret_salt = 'cookie'
  super
end

Instance Attribute Details

#account_user_mapperObject

account_user_mapper This class teaches the gem how to convert between accounts and users See the “account_user_mapper” discussion in the README



46
47
48
# File 'lib/openstax/accounts/configuration.rb', line 46

def 
  @account_user_mapper
end

#default_errors_added_triggerObject

Returns the value of attribute default_errors_added_trigger.



37
38
39
# File 'lib/openstax/accounts/configuration.rb', line 37

def default_errors_added_trigger
  @default_errors_added_trigger
end

#default_errors_html_idObject

Returns the value of attribute default_errors_html_id.



36
37
38
# File 'lib/openstax/accounts/configuration.rb', line 36

def default_errors_html_id
  @default_errors_html_id
end

#default_errors_partialObject

Returns the value of attribute default_errors_partial.



35
36
37
# File 'lib/openstax/accounts/configuration.rb', line 35

def default_errors_partial
  @default_errors_partial
end

#enable_stubbingObject

enable_stubbing Set to true if you want this engine to fake all interaction with the accounts site.



29
30
31
# File 'lib/openstax/accounts/configuration.rb', line 29

def enable_stubbing
  @enable_stubbing
end

#forwardable_login_paramsObject

forwardable_login_params Which params are forwarded on the accounts login path



76
77
78
# File 'lib/openstax/accounts/configuration.rb', line 76

def 
  @forwardable_login_params
end

#logout_handlerObject

logout_handler Handles logging out and redirecting user when they’ve requested logout if specified, the logout_redirect_url has no effect



63
64
65
# File 'lib/openstax/accounts/configuration.rb', line 63

def logout_handler
  @logout_handler
end

#logout_redirect_url(request) ⇒ Object



99
100
101
102
103
104
# File 'lib/openstax/accounts/configuration.rb', line 99

def logout_redirect_url(request)
  (@logout_redirect_url.is_a?(Proc) ?
     @logout_redirect_url.call(request) :
     @logout_redirect_url) ||
  default_logout_redirect_url
end

#logout_viaObject

logout_via HTTP method to accept for logout requests



33
34
35
# File 'lib/openstax/accounts/configuration.rb', line 33

def logout_via
  @logout_via
end

#max_search_itemsObject

max_search_items The maximum number of accounts that can be returned in a call to the AccountsSearch handler If more would be returned, the result will be empty instead



58
59
60
# File 'lib/openstax/accounts/configuration.rb', line 58

def max_search_items
  @max_search_items
end

#max_user_updates_per_requestObject

max_user_updates_per_request When the user profile sync operation is called, this parameter will limit the number of returned profile updates from Accounts; helpful when all accounts have been marked as updated on Accounts so that we don’t get overloaded.



83
84
85
# File 'lib/openstax/accounts/configuration.rb', line 83

def max_user_updates_per_request
  @max_user_updates_per_request
end

#min_search_charactersObject

min_search_characters The minimum number of characters that can be used as a query in a call to the AccountsSearch handler If less are used, the handler will return an error instead



52
53
54
# File 'lib/openstax/accounts/configuration.rb', line 52

def min_search_characters
  @min_search_characters
end

#openstax_accounts_urlObject

openstax_accounts_url Base URL for OpenStax Accounts



6
7
8
# File 'lib/openstax/accounts/configuration.rb', line 6

def openstax_accounts_url
  @openstax_accounts_url
end

#openstax_application_idObject

openstax_application_id OAuth client_id received from OpenStax Accounts



20
21
22
# File 'lib/openstax/accounts/configuration.rb', line 20

def openstax_application_id
  @openstax_application_id
end

#openstax_application_secretObject

openstax_application_secret OAuth client_secret received from OpenStax Accounts



24
25
26
# File 'lib/openstax/accounts/configuration.rb', line 24

def openstax_application_secret
  @openstax_application_secret
end

#return_to_url_approver=(value) ⇒ Object (writeonly)

Sets the attribute return_to_url_approver

Parameters:

  • value

    the value to set the attribute return_to_url_approver to.



110
111
112
# File 'lib/openstax/accounts/configuration.rb', line 110

def return_to_url_approver=(value)
  @return_to_url_approver = value
end

#security_transgression_exceptionObject

security_transgression_exception Class to be used for security transgression exceptions



41
42
43
# File 'lib/openstax/accounts/configuration.rb', line 41

def security_transgression_exception
  @security_transgression_exception
end

sso_cookie_name The name of the cookie that stores the SSO session. Defaults to ‘ox’



97
98
99
# File 'lib/openstax/accounts/configuration.rb', line 97

def sso_cookie_name
  @sso_cookie_name
end

#sso_secret_keyObject

sso_secret_key The secret key used to decode the SSO cookie will be used to decryp the shared user session set by accounts when a user logs in, and cleared when they logout



89
90
91
# File 'lib/openstax/accounts/configuration.rb', line 89

def sso_secret_key
  @sso_secret_key
end

#sso_secret_saltObject

sso_secret_salt The salt that should be used to decypt the SSO session. Defaults to ‘cookie’



93
94
95
# File 'lib/openstax/accounts/configuration.rb', line 93

def sso_secret_salt
  @sso_secret_salt
end

Instance Method Details

#default_logout_redirect_urlObject



106
107
108
# File 'lib/openstax/accounts/configuration.rb', line 106

def default_logout_redirect_url
  URI.join(openstax_accounts_url, 'logout').to_s
end

#enable_stubbing?Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/openstax/accounts/configuration.rb', line 145

def enable_stubbing?
  !Rails.env.production? && enable_stubbing
end

#is_return_to_url_approved?(return_to_url) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
115
116
# File 'lib/openstax/accounts/configuration.rb', line 112

def is_return_to_url_approved?(return_to_url)
  return_to_url &&
  @return_to_url_approver.is_a?(Proc) &&
  @return_to_url_approver.call(return_to_url)
end