Sha256: d50a89ab50f9717cf87614de5f2df313806e2993f8434356bd05c74c9c5502f3

Contents?: true

Size: 1.31 KB

Versions: 15

Compression:

Stored size: 1.31 KB

Contents

module Softwear
  module Auth
    class Controller < ::ApplicationController
      skip_before_filter :authenticate_user!, only: [:set_session_token, :clear_query_cache]

      def self.abstract_class?
        true
      end

      # ====================
      # Comes from an img tag on softwear-hub to let an authorized app know that
      # a user has signed in.
      # ====================
      def set_session_token
        encrypted_token = params[:token]
        redirect_to Figaro.env.softwear_hub_url and return if encrypted_token.blank?

        Rails.logger.info "RECEIVED ENCRYPTED TOKEN: #{encrypted_token}"

        decipher = OpenSSL::Cipher::AES.new(256, :CBC)
        decipher.decrypt
        decipher.key = Figaro.env.token_cipher_key
        decipher.iv  = Figaro.env.token_cipher_iv

        session[:user_token] = decipher.update(Base64.urlsafe_decode64(encrypted_token)) + decipher.final

        render inline: 'Done'
      end

      # ====================
      # Comes from an img tag on softwear-hub when there has been a change to user
      # attributes or roles and the cache should be cleared.
      # ====================
      def clear_query_cache
        Softwear::Auth::Model.descendants.each do |user|
          user.query_cache.clear
        end

        render inline: 'Done'
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
softwear-lib-3.1.2 lib/softwear/auth/controller.rb
softwear-lib-3.1.1 lib/softwear/auth/controller.rb
softwear-lib-3.1.0 lib/softwear/auth/controller.rb
softwear-lib-3.0.0 lib/softwear/auth/controller.rb
softwear-lib-2.1.7 lib/softwear/auth/controller.rb
softwear-lib-2.1.6 lib/softwear/auth/controller.rb
softwear-lib-2.1.4 lib/softwear/auth/controller.rb
softwear-lib-2.1.3 lib/softwear/auth/controller.rb
softwear-lib-2.1.2 lib/softwear/auth/controller.rb
softwear-lib-2.1.1 lib/softwear/auth/controller.rb
softwear-lib-2.1.0 lib/softwear/auth/controller.rb
softwear-lib-2.0.13 lib/softwear/auth/controller.rb
softwear-lib-2.0.12 lib/softwear/auth/controller.rb
softwear-lib-2.0.11 lib/softwear/auth/controller.rb
softwear-lib-2.0.10 lib/softwear/auth/controller.rb