Sha256: 198be339c18b74f54c66fdd991592f35c494204b63d91d8a8de75fce74e069f9
Contents?: true
Size: 715 Bytes
Versions: 7
Compression:
Stored size: 715 Bytes
Contents
module Wazuh module Sawyer module Connection class Token def self.jwt(endpoint, options, basic_user, basic_password) if !@_token || (@_exp && @_exp -3 <= Time.now.to_i) options[:url] = endpoint options[:headers].merge!({'Authorization' => "Basic " + Base64.strict_encode64(basic_user + ':' + basic_password).strip}) token = ::Faraday.new(options) {|f| f.response :json }.get('/security/user/authenticate').body['data']['token'] @_exp = ::JWT.decode(token, nil, false).first['exp'].to_i ::JWT.decode(token, nil, false).first @_token = token end @_token end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems