Class: Wurk::API::Auth::Principal

Inherits:
Struct
  • Object
show all
Defined in:
lib/wurk/api/auth.rb

Overview

What the request proved about itself: the scopes it was granted, and a stable label for the credential that granted them. id is a truncated domain-separated digest, never the token — enough to namespace per-credential state (an Idempotency-Key record belongs to the producer that chose it, not to whoever guesses the same string), and nothing a holder could work backwards from.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



63
64
65
# File 'lib/wurk/api/auth.rb', line 63

def id
  @id
end

#scopesObject

Returns the value of attribute scopes

Returns:

  • (Object)

    the current value of scopes



63
64
65
# File 'lib/wurk/api/auth.rb', line 63

def scopes
  @scopes
end

Instance Method Details

#permits?(scope) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/wurk/api/auth.rb', line 64

def permits?(scope)
  scope == ANY || scopes.include?(scope) || scopes.include?(:admin)
end