added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
require "openssl"
class DiscourseClient
def initialize(user, params = {})
@user = user
@params = params
end
def generate_url
uri = URI(ENV.fetch("DISCOURSE_AUTH_URL"))
if OpenSSL::HMAC.hexdigest("sha256", ENV.fetch("DISCOURSE_SECRET"), sso) == sig
nonce = Base64.decode64(sso)
sso = Base64.encode64(nonce + "&email=" + @user.email + "&external_id=" + @user.external_id)
sig = OpenSSL::HMAC.hexdigest("sha256", ENV.fetch("DISCOURSE_SECRET"), sso)
uri.query = {sso: sso, sig: sig}.to_query
end
uri.to_s
end
private
def sig
@params.fetch(:sig)
end
def sso
@params.fetch(:sso)
end
end