lib/conjur/api.rb in conjur-api-4.6.1 vs lib/conjur/api.rb in conjur-api-4.7.1
- old
+ new
@@ -49,9 +49,22 @@
def to_json(options = {})
{}
end
+ def conjur_api
+ Conjur::API.new_from_token token
+ end
+
+ def token
+ authorization = options[:headers][:authorization]
+ if authorization && authorization.to_s[/^Token token="(.*)"/]
+ JSON.parse(Base64.decode64($1))
+ else
+ raise AuthorizationError.new("Authorization missing")
+ end
+ end
+
def username
options[:user] || options[:username]
end
end
\ No newline at end of file