Something went wrong. Try again.
Don't forget to lycansubscribe 🐺
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536require 'jose'require 'json'
namespace :oauth do task :generate_keys do key = JOSE::JWK.generate_key([:ec, "P-256"]) key_id = "key-#{Time.now.to_i}"
private_jwk = key.to_map.to_h.merge("kid" => key_id, "use" => "sig") public_jwk = key.to_public_map.to_h.merge("kid" => key_id, "use" => "sig")
puts "=" * 40 puts "PRIVATE KEY".center(40) puts "=" * 40
puts puts "Copy this JSON into config/oauth_keys.json. This is a private key that should not be available publicly." puts
puts JSON.pretty_generate('keys' => [private_jwk]) puts
puts "=" * 40 puts "PUBLIC KEY".center(40) puts "=" * 40
puts puts "Copy this JSON into config/oauth_metadata.json. This is a public key read by the authorization " + "server so that it can validate the client assertions generated by your app." puts
puts JSON.pretty_generate('jwks' => { 'keys' => [public_jwk] }) puts endend