Sha256: 6fcd08532ee20ad958a508954ef7427f6cd1ed77e5f6305b85177d7826b76058
Contents?: true
Size: 708 Bytes
Versions: 1
Compression:
Stored size: 708 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.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wazuh-ruby-client-0.3.0 | lib/wazuh/sawyer/token.rb |