mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
fixed bot安装仓库列表必须使用access_tokens获取到bot的token才能查询
This commit is contained in:
32
test/jwt_github_test.rb
Normal file
32
test/jwt_github_test.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'openssl'
|
||||
require 'jwt' # https://rubygems.org/gems/jwt
|
||||
|
||||
# Private key contents
|
||||
private_pem = File.read("/Users/xxq/Documents/gitlink-webhook.2022-06-09.private-key.pem")
|
||||
private_key = OpenSSL::PKey::RSA.new(private_pem)
|
||||
|
||||
# Generate the JWT
|
||||
payload = {
|
||||
# issued at time, 60 seconds in the past to allow for clock drift
|
||||
iat: Time.now.to_i - 60,
|
||||
# JWT expiration time (10 minute maximum)
|
||||
exp: Time.now.to_i + (10 * 60),
|
||||
# GitHub App's identifier
|
||||
iss: "209248"
|
||||
}
|
||||
|
||||
jwt = JWT.encode(payload, private_key, "RS256")
|
||||
puts jwt
|
||||
# puts OpenSSL::PKey::RSA.new(private_key33).public_key.to_s
|
||||
#
|
||||
# rsa_private = OpenSSL::PKey::RSA.new(private_key33)
|
||||
# rsa_public = rsa_private.public_key
|
||||
#
|
||||
#
|
||||
|
||||
# puts decoded_token[0]
|
||||
# puts decoded_token[0]["iss"]
|
||||
|
||||
# serialized_private_key = OpenSSL::PKey::RSA::generate(2048).to_s
|
||||
|
||||
|
||||
Reference in New Issue
Block a user