diff options
| author | mo khan <mo@mokhan.ca> | 2025-02-28 15:38:33 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-02-28 15:38:33 -0700 |
| commit | 159b5abe4d26593c2442c786bebbd04829164808 (patch) | |
| tree | ceccfa0c15204314c978c17cdcabcbd150bd15d7 /bin/idp | |
| parent | 68f60576334bb0db8c8d9c579b3d60326aaff512 (diff) | |
feat: add a simple grant exchange endpoint
Diffstat (limited to 'bin/idp')
| -rwxr-xr-x | bin/idp | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -77,7 +77,12 @@ class IdentityProvider when "/oauth/authorize" # RFC-6749 return post_authorize(Rack::Request.new(env)) when "/oauth/token" # RFC-6749 - return not_found + return [200, { 'Content-Type' => "application/json" }, [JSON.pretty_generate({ + access_token: to_jwt(sub: SecureRandom.uuid, iat: Time.now.to_i), + token_type: "Bearer", + expires_in: 3600, + refresh_token: SecureRandom.hex(32) + })]] when "/oauth/revoke" # RFC-7009 return not_found else @@ -89,6 +94,14 @@ class IdentityProvider private + def to_jwt(claims) + [ + Base64.strict_encode64(JSON.generate({alg: "RS256", typ: "JWT"})), + Base64.strict_encode64(JSON.generate(claims)), + Base64.strict_encode64(JSON.generate({})), + ].join(".") + end + # Download IDP Metadata # # GET /metadata.xml |
