Class: Masks::Credentials::Key

Inherits:
Masks::Credential show all
Defined in:
app/models/masks/credentials/key.rb

Overview

Checks :key given a valid Authorization header.

Instance Method Summary collapse

Methods inherited from Masks::Credential

#backup!, #check, checks, #cleanup, #cleanup!, #mask!, #name, #patch_params, #slug

Instance Method Details

#backupObject



33
34
35
# File 'app/models/masks/credentials/key.rb', line 33

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

#lookupObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/masks/credentials/key.rb', line 11

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

#maskupObject



23
24
25
26
27
28
29
30
31
# File 'app/models/masks/credentials/key.rb', line 23

def maskup
  key = session.extra(:key)

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