Sha256: 4a2583fce00691351257afee98d7fcf60919a8885ca9b7fa70a67d689b2f120b

Contents?: true

Size: 613 Bytes

Versions: 4

Compression:

Stored size: 613 Bytes

Contents

# frozen_string_literal: true

module ShibRack
  # Mixin providing the default implementation of a subject receiver
  module DefaultReceiver
    def receive(env)
      attrs = map_attributes(env)
      store_id(env, subject(env, attrs).id)
      finish(env)
    end

    def map_attributes(_env)
      {}
    end

    def store_id(env, id)
      env['rack.session']['subject_id'] = id
    end

    def finish(_env)
      redirect_to('/')
    end

    def redirect_to(url)
      [302, { 'Location' => url }, []]
    end

    def logout(env)
      env['rack.session'].clear
      redirect_to('/')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shib-rack-0.4.0 lib/shib_rack/default_receiver.rb
shib-rack-0.3.0 lib/shib_rack/default_receiver.rb
shib-rack-0.2.0 lib/shib_rack/default_receiver.rb
shib-rack-0.1.0 lib/shib_rack/default_receiver.rb