summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-03-20 09:50:46 -0600
committermo khan <mo@mokhan.ca>2025-03-20 09:50:46 -0600
commit761d493d61bda7449f117cc333e45682bed14578 (patch)
treec411ddd07919cae1fe0dad057bbe1ee9c49fe640 /bin
parentb9c16b58e777a9b7c5e9fb47fd72677609821434 (diff)
feat: add logout and links to /index.html
Diffstat (limited to 'bin')
-rwxr-xr-xbin/api1
-rwxr-xr-xbin/ui21
2 files changed, 16 insertions, 6 deletions
diff --git a/bin/api b/bin/api
index 3fa550c..feb00ca 100755
--- a/bin/api
+++ b/bin/api
@@ -89,6 +89,7 @@ module HTTPHelpers
permission: permission,
resource: resource.to_gid.to_s,
}, headers: { 'Authorization' => "Bearer #{authorization.params}"})
+ puts [response&.data&.result, permission, resource.to_gid.to_s].inspect
response.error.nil? && response.data.result
end
diff --git a/bin/ui b/bin/ui
index a08ff68..2bef8ee 100755
--- a/bin/ui
+++ b/bin/ui
@@ -145,15 +145,19 @@ class UI
<html>
<head><title></title></head>
<body style="background-color: pink;">
- <a href="/saml/new">SAML Login</a>
- <a href="/oidc/new">OIDC Login</a>
- <%- if request.session[:access_token] -%>
+ <%- if current_user?(request) -%>
+ <a href="/groups.html">Groups</a>
<h1>Access Token</h1>
<pre><%= request.session[:access_token] %></pre>
- <%- end -%>
- <%- if request.session[:id_token] -%>
<h1>ID Token</h1>
<pre><%= request.session[:id_token] %></pre>
+
+ <form action="/logout" method="post">
+ <input type="submit" value="Logout" />
+ </form>
+ <%- else -%>
+ <a href="/saml/new">SAML Login</a>
+ <a href="/oidc/new">OIDC Login</a>
<%- end -%>
</body>
</html>
@@ -186,7 +190,9 @@ class UI
when Rack::POST
case request.path
when "/logout"
- request.session.delete(:user_id)
+ request.session.delete(:access_token)
+ request.session.delete(:id_token)
+ request.session.delete(:refresh_token)
return redirect_to("/")
when "/saml/assertions"
return saml_assertions(Rack::Request.new(env))
@@ -229,6 +235,7 @@ class UI
<body style="background-color: pink;">
<pre style="display: none;"><%= response.body %></pre>
<pre><%= JSON.pretty_generate(request.session[:access_token]) %></pre>
+ <a href="/index.html">Home</a>
<a href="/groups.html">Groups</a>
</body>
</html>
@@ -255,6 +262,7 @@ class UI
<title></title>
</head>
<body style="background-color: pink;">
+ <a href="/index.html">Home</a>
<a href="/groups.html">Groups</a>
<form action="/logout" method="post">
<input type="submit" value="Logout" />
@@ -307,6 +315,7 @@ class UI
<title></title>
</head>
<body style="background-color: pink;">
+ <a href="/index.html">Home</a>
<a href="/groups.html">Groups</a>
<table>
<thead>