Class: CognitoIdpRails::Configuration

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

Constant Summary collapse

REQUIRED_ATTRIBUTES =
%i[domain client_id client_secret].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
15
# File 'lib/cognito_idp_rails/configuration.rb', line 8

def initialize
  @after_login_route = "/"
  @after_logout_route = "/"
  @after_login = lambda { |token, , request| }
  @before_logout = lambda { |request| }
  @on_login_error = lambda { |error, request| }
  @scope = "openid"
end

Instance Attribute Details

#after_loginObject

Returns the value of attribute after_login.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def 
  @after_login
end

#after_login_routeObject

Returns the value of attribute after_login_route.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def 
  @after_login_route
end

#after_logout_routeObject

Returns the value of attribute after_logout_route.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def after_logout_route
  @after_logout_route
end

#before_logoutObject

Returns the value of attribute before_logout.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def before_logout
  @before_logout
end

#client_idObject

Returns the value of attribute client_id.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def client_secret
  @client_secret
end

#domainObject

Returns the value of attribute domain.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def domain
  @domain
end

#on_login_errorObject

Returns the value of attribute on_login_error.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def 
  @on_login_error
end

#scopeObject

Returns the value of attribute scope.



3
4
5
# File 'lib/cognito_idp_rails/configuration.rb', line 3

def scope
  @scope
end

Instance Method Details

#validate!Object

Raises:



17
18
19
20
21
22
# File 'lib/cognito_idp_rails/configuration.rb', line 17

def validate!
  missing = REQUIRED_ATTRIBUTES.select { |attr| public_send(attr).nil? }
  return if missing.empty?

  raise ConfigurationError, "Missing required configuration: #{missing.join(", ")}"
end