Sha256: cda56fe8d5a4e295b113b86cf0e04a85fb02f9fb5d28f87cca4db53671f6e000

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

require 'selfsdk'

if defined?(Rails::Server) && !defined?(::SelfClient)
  # If self client is already initialized skip this initialization
  return unless defined?(::SelfClient).nil?

  # Initializes self client
  ::SelfClient = SelfSDK::App.new(
    ENV['SELF_APP_ID'],
    ENV['SELF_APP_KEY'],
    ENV['SELF_STORAGE_KEY'],
    ENV['SELF_STORAGE_DIR'],
    env: ENV['SELF_ENVIRONMENT'],
  )

  # Setup self-auth-rails engine
  SelfAuthRails.setup do |config|
    # Initializes the self-ruby-sdk client.
    config.self_client = ::SelfClient

    # Sets rails logger as default self-ruby-sdk logger (optional).
    SelfSDK.logger = Rails.logger

    # Defines the facts we're going to require for a user to authenticate.
    # If not provided it will default to [:display_name].
    config.auth_facts = [:display_name, :email_address]

    # Defines the model class name to be used for persistance. The active
    # model provided must have `selfid` and `token` attributes. 
    # Note this config entry is optional and defaults to `User`.
    config.session_class_name = 'User'

    # Defines the path to redirect the user when authentication succeeds.
    # Optional entry defaulting to '/'.
    config.authenticated_path = '/'

    # Defines the layout to be used for the authentication page.
    # config.layout = 'login'

    # In case you want to persist the authentication returning facts, you 
    # can provide a map for the fact_name and the ActiveModel object property.
    #
    # This is an optional entry and you only need to provide it if you're intending
    # to request and store facts during the authentication process with 
    # config.auth_facts
    config.fact_mapping = { display_name: :name }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
self-auth-rails-0.1.2 lib/tasks/initializer.rb.tpl