summaryrefslogtreecommitdiff
path: root/bin/sp
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-02-28 15:38:33 -0700
committermo khan <mo@mokhan.ca>2025-02-28 15:38:33 -0700
commit159b5abe4d26593c2442c786bebbd04829164808 (patch)
treececcfa0c15204314c978c17cdcabcbd150bd15d7 /bin/sp
parent68f60576334bb0db8c8d9c579b3d60326aaff512 (diff)
feat: add a simple grant exchange endpoint
Diffstat (limited to 'bin/sp')
-rwxr-xr-xbin/sp12
1 files changed, 11 insertions, 1 deletions
diff --git a/bin/sp b/bin/sp
index fa22efd0..99eae914 100755
--- a/bin/sp
+++ b/bin/sp
@@ -7,6 +7,7 @@ gemfile do
gem "base64", "~> 0.1"
gem "erb", "~> 4.0"
+ gem "net-hippie", "~> 1.0"
gem "rack", "~> 3.0"
gem "rackup", "~> 2.0"
gem "saml-kit", "~> 1.0"
@@ -89,7 +90,16 @@ class ServiceProvider
def oauth_callback(request)
# TODO:: Exchange grant (authorization_code) for an access token
- [200, { "Content-Type" => "application/json" }, [JSON.pretty_generate(request.params)]]
+ response = Net::Hippie.default_client.post(
+ "http://localhost:8282/oauth/token",
+ headers: { 'Authorization' => Net::Hippie.basic_auth('client_id', 'secret') },
+ body: {
+ grant_type: "authorization_code",
+ code: request.params['code'],
+ code_verifier: "not_implemented"
+ }
+ )
+ [200, { "Content-Type" => "application/json" }, [JSON.pretty_generate(request.params.merge(JSON.parse(response.body)))]]
end
def saml_post_to_idp(request)