Sha256: ee4c9feb158ce50568d6fb06815ba1c7e3d35addf8fe5521e439cb34071220d2
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require 'webmock/minitest' module Keratin::AuthN module Test module Helpers JWS_ALGORITHM = 'RS256' # a factory for JWT id_tokens private def id_token_for(subject) JSON::JWT.new( iss: Keratin::AuthN.config.issuer, aud: Keratin::AuthN.config.audience, sub: subject, iat: 10.seconds.ago, exp: 1.hour.from_now ).sign(jws_keypair, JWS_ALGORITHM).to_s end # a temporary RSA key for our test suite. # # generates the smallest (fastest) key possible for RS256 private def jws_keypair @keypair ||= OpenSSL::PKey::RSA.new(512) end # stubs the endpoints necessary to validate a signed JWT private def stub_auth_server stub_request(:get, "#{Keratin::AuthN.config.issuer}#{Keratin::AuthN.config.configuration_path}").to_return( status: 200, body: {'jwks_uri' => "#{Keratin::AuthN.config.issuer}/jwks"}.to_json ) stub_request(:get, "#{Keratin::AuthN.config.issuer}/jwks").to_return( status: 200, body: { keys: [ jws_keypair.public_key.to_jwk.slice(:kty, :kid, :e, :n).merge( use: 'sig', alg: JWS_ALGORITHM ) ] }.to_json ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
keratin-authn-0.1.0 | lib/keratin/authn/test/helpers.rb |