diff options
| author | mo khan <mo@mokhan.ca> | 2025-03-20 09:41:34 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-03-20 09:41:34 -0600 |
| commit | b9c16b58e777a9b7c5e9fb47fd72677609821434 (patch) | |
| tree | ebc0a320c207591db09332099c3598d6394eee14 | |
| parent | 4d0c6c388269d52eb20b5fc420965d124c38aa4b (diff) | |
refactor: extract ui.example.com/index.html and print tokens
| -rwxr-xr-x | bin/ui | 35 | ||||
| -rw-r--r-- | policy.csv | 1 |
2 files changed, 32 insertions, 4 deletions
@@ -139,6 +139,27 @@ class UI case request.request_method when Rack::GET case request.path + when "/index.html" + template = <<~ERB + <!DOCTYPE html> + <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] -%> + <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> + <%- end -%> + </body> + </html> + ERB + html = ERB.new(template, trim_mode: '-').result(binding) + return [200, { 'Content-Type' => "text/html" }, [html]] when "/groups.html" if current_user?(request) return get_groups(request) @@ -160,10 +181,13 @@ class UI when "/saml/new" return saml_post_to_idp(Rack::Request.new(env)) else - return redirect_to("/saml/new") + return redirect_to("/index.html") end when Rack::POST case request.path + when "/logout" + request.session.delete(:user_id) + return redirect_to("/") when "/saml/assertions" return saml_assertions(Rack::Request.new(env)) else @@ -202,7 +226,7 @@ class UI <!DOCTYPE html> <html> <head><title></title></head> - <body> + <body style="background-color: pink;"> <pre style="display: none;"><%= response.body %></pre> <pre><%= JSON.pretty_generate(request.session[:access_token]) %></pre> <a href="/groups.html">Groups</a> @@ -230,8 +254,11 @@ class UI <head> <title></title> </head> - <body> + <body style="background-color: pink;"> <a href="/groups.html">Groups</a> + <form action="/logout" method="post"> + <input type="submit" value="Logout" /> + </form> <table> <thead> <tr> @@ -279,7 +306,7 @@ class UI <head> <title></title> </head> - <body> + <body style="background-color: pink;"> <a href="/groups.html">Groups</a> <table> <thead> @@ -10,3 +10,4 @@ p, *, ui.example.com, (GET)|(POST), /oauth* p, *, ui.example.com, (GET)|(POST), /oidc* p, *, ui.example.com, (GET)|(POST), /saml* p, *, ui.example.com, (GET), /*.html +p, *, ui.example.com, (POST), /logout |
