Class: InfinumAzure::Config

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

Constant Summary collapse

PROVIDER_INFINUM_ID =
'infinum_id'
PROVIDER_INFINUM_AZURE =
'infinum_azure'
UID =
'uid'
DEFAULT_RESOURCE_ATTRIBUTES =
[
  :uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :groups, :employee
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



22
23
24
25
26
27
28
29
30
31
# File 'lib/infinum_azure/config.rb', line 22

def initialize
  self.resource_attributes = DEFAULT_RESOURCE_ATTRIBUTES
  self.user_migration_scope = -> { InfinumAzure.resource_class.where(provider: PROVIDER_INFINUM_ID) }
  self.user_migration_operation = lambda { |record, resource|
    record.update_columns( # rubocop:disable Rails/SkipsModelValidations
      provider: PROVIDER_INFINUM_AZURE,
      uid: resource[UID]
    )
  }
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



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

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



17
18
19
# File 'lib/infinum_azure/config.rb', line 17

def client_secret
  @client_secret
end

#domainObject

Returns the value of attribute domain.



18
19
20
# File 'lib/infinum_azure/config.rb', line 18

def domain
  @domain
end

#resource_attributesObject

Returns the value of attribute resource_attributes.



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

def resource_attributes
  @resource_attributes
end

#resource_nameObject

Returns the value of attribute resource_name.



12
13
14
# File 'lib/infinum_azure/config.rb', line 12

def resource_name
  @resource_name
end

#tenantObject

Returns the value of attribute tenant.



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

def tenant
  @tenant
end

#user_migration_operationObject

Returns the value of attribute user_migration_operation.



15
16
17
# File 'lib/infinum_azure/config.rb', line 15

def user_migration_operation
  @user_migration_operation
end

#user_migration_scopeObject

Returns the value of attribute user_migration_scope.



14
15
16
# File 'lib/infinum_azure/config.rb', line 14

def user_migration_scope
  @user_migration_scope
end

#users_auth_urlObject

Returns the value of attribute users_auth_url.



20
21
22
# File 'lib/infinum_azure/config.rb', line 20

def users_auth_url
  @users_auth_url
end

Instance Method Details

#validate!Object



33
34
35
36
37
38
# File 'lib/infinum_azure/config.rb', line 33

def validate!
  [:resource_name, :resource_attributes, :user_migration_scope, :user_migration_operation, :client_id,
   :client_secret, :domain, :tenant].each do |attribute|
    raise InfinumAzure::Error, "InfinumAzure attribute '@#{attribute}' not set" if public_send(attribute).blank?
  end
end