Class: Masks::Rails::OpenID::AccessToken

Inherits:
ApplicationRecord show all
Includes:
Scoped
Defined in:
app/models/masks/rails/openid/access_token.rb

Instance Method Summary collapse

Methods included from Scoped

#role?, #role_records, #scope?

Instance Method Details

#roles(*args, **opts) ⇒ Object



34
35
36
# File 'app/models/masks/rails/openid/access_token.rb', line 34

def roles(*args, **opts)
  (actor || openid_client).roles(*args, **opts)
end

#scopesObject



26
27
28
29
30
31
32
# File 'app/models/masks/rails/openid/access_token.rb', line 26

def scopes
  value = self[:scopes]

  return [] unless value

  value & ((actor&.scopes || []) + openid_client.scopes)
end

#to_bearer_tokenObject



38
39
40
41
42
43
# File 'app/models/masks/rails/openid/access_token.rb', line 38

def to_bearer_token
  Rack::OAuth2::AccessToken::Bearer.new(
    access_token: token,
    expires_in: (expires_at - Time.now.utc).to_i
  )
end