Module: Aspera::Plugins::Node::Api::Scope
Overview
Format of node scope : node.
Constant Summary collapse
- USER =
Node sub-scopes
'user:all'- ADMIN =
'admin:all'- SEPARATOR =
Separator between node.AK and user:all
':'- NODE_PREFIX =
'node.'
Instance Method Summary collapse
-
#join(access_key:, scope:) ⇒ String
Encode node API scope.
-
#split(scope) ⇒ Hash
Decode node scope into access key and scope.
Instance Method Details
#join(access_key:, scope:) ⇒ String
Encode node API scope
60 61 62 |
# File 'lib/aspera/plugins/node/api.rb', line 60 def join(access_key:, scope:) ["#{NODE_PREFIX}#{access_key}", scope].join(SEPARATOR) end |
#split(scope) ⇒ Hash
Decode node scope into access key and scope
67 68 69 70 71 72 |
# File 'lib/aspera/plugins/node/api.rb', line 67 def split(scope) items = scope.split(Scope::SEPARATOR, 2) Aspera.assert(items.length.eql?(2)) { "invalid scope: #{scope}" } Aspera.assert(items[0].start_with?(NODE_PREFIX)) { "invalid scope: #{scope}" } {access_key: items[0].delete_prefix(NODE_PREFIX), scope: items[1]} end |