Sha256: aecb97873f7de18c604d61faf9c44990a429984a1ba66dfa8b9d5a4b6c76b4d4

Contents?: true

Size: 989 Bytes

Versions: 4

Compression:

Stored size: 989 Bytes

Contents

module Warden
  module GitHub
    module SSO
      def warden_github_sso_session_valid?(user, expiry_in_seconds = 30)
        return true if defined?(::Rails) && ::Rails.env.test?
        if warden_github_sso_session_needs_reverification?(user, expiry_in_seconds)
          if user.browser_session_valid?(expiry_in_seconds)
            warden_github_sso_session_reverify!
            return true
          end
          return false
        end
        true
      end

      def warden_github_sso_session_verified_at
        session[:warden_github_sso_session_verified_at] || Time.now.utc.to_i - 86400
      end

      def warden_github_sso_session_reverify!
        session[:warden_github_sso_session_verified_at] = Time.now.utc.to_i
      end

      def warden_github_sso_session_needs_reverification?(user, expiry_in_seconds)
        user.using_single_sign_out? &&
          (warden_github_sso_session_verified_at <= (Time.now.utc.to_i - expiry_in_seconds))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
warden-github-1.3.2 lib/warden/github/sso.rb
warden-github-1.3.1 lib/warden/github/sso.rb
warden-github-1.3.0 lib/warden/github/sso.rb
warden-github-1.2.0 lib/warden/github/sso.rb