Class: Masks::Credentials::AccessToken

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

Overview

Checks :key given a valid Authorization header.

Instance Method Summary collapse

Methods inherited from Masks::Credential

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

Instance Method Details

#lookupObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/masks/credentials/access_token.rb', line 9

def lookup
  access_token =
    session.config.model(:openid_access_token).valid.find_by(token:)

  return unless access_token&.actor

  session.extras(access_token:)
  session.scoped = access_token

  access_token.actor
end

#maskupObject



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

def maskup
  access_token = session.extra(:access_token)

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