Sha256: a15bcb78dd1e5e35a4237291970b79df6ea6e6ea1f9dd734416ec0dbc484da52

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true

module Masks
  module Credentials
    # Checks :key given a valid Authorization header.
    class Key < Masks::Credential
      checks :key

      attribute :accessed

      def lookup
        secret = session.request.authorization&.split&.last
        key = session.config.find_key(session, secret:)

        return unless key

        session.extras(key:)
        session.scoped = key
        self.accessed = true
        key.actor
      end

      def maskup
        key = session.extra(:key)

        if key&.actor == session&.actor && session.scoped == key
          approve!
        else
          deny!
        end
      end

      def backup
        session.scoped.touch(:accessed_at) if session&.passed? && accessed
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
masks-0.3.2 app/models/masks/credentials/key.rb
masks-0.3.1 app/models/masks/credentials/key.rb
masks-0.3.0 app/models/masks/credentials/key.rb
masks-0.2.0 app/models/masks/credentials/key.rb