Commit c55e51e
Changed files (1)
bin
bin/ui
@@ -172,44 +172,7 @@ class UI
when Rack::GET
case request.path
when "/index.html"
- html = with_layout(binding) do
- <<~ERB
- <%- if current_user?(request) -%>
- <nav>
- <ul>
- <li><a href="http://#{$idp_host}/">IdP</a></li>
- <li><strong>UI</strong></li>
- </ul>
- <ul>
- <li><a href="/index.html">Home</a></li>
- <li><a href="/groups.html">Groups</a></li>
- <li>
- <form action="/logout" method="post">
- <input type="submit" value="Logout" />
- </form>
- </li>
- </ul>
- </nav>
- <h1>Access Token</h1>
- <pre><%= request.session[:access_token] %></pre>
-
- <h1>ID Token</h1>
- <pre><%= request.session[:id_token] %></pre>
- <%- else -%>
- <nav>
- <ul>
- <li><a href="http://#{$idp_host}/">IdP</a></li>
- <li><strong>UI</strong></li>
- </ul>
- <ul>
- <li><a href="/saml/new">SAML Login</a></li>
- <li><a href="/oidc/new">OIDC Login</a></li>
- </ul>
- </nav>
- <%- end -%>
- ERB
- end
- return [200, { 'Content-Type' => "text/html" }, [html]]
+ return get_index(request)
when "/groups.html"
if current_user?(request)
return get_groups(request)
@@ -268,6 +231,47 @@ class UI
[200, { 'Content-Type' => "application/samlmetadata+xml" }, [xml]]
end
+ def get_index(request)
+ html = with_layout(binding) do
+ <<~ERB
+ <%- if current_user?(request) -%>
+ <nav>
+ <ul>
+ <li><a href="http://#{$idp_host}/">IdP</a></li>
+ <li><strong>UI</strong></li>
+ </ul>
+ <ul>
+ <li><a href="/index.html">Home</a></li>
+ <li><a href="/groups.html">Groups</a></li>
+ <li>
+ <form action="/logout" method="post">
+ <input type="submit" value="Logout" />
+ </form>
+ </li>
+ </ul>
+ </nav>
+ <h1>Access Token</h1>
+ <pre><%= request.session[:access_token] %></pre>
+
+ <h1>ID Token</h1>
+ <pre><%= request.session[:id_token] %></pre>
+ <%- else -%>
+ <nav>
+ <ul>
+ <li><a href="http://#{$idp_host}/">IdP</a></li>
+ <li><strong>UI</strong></li>
+ </ul>
+ <ul>
+ <li><a href="/saml/new">SAML Login</a></li>
+ <li><a href="/oidc/new">OIDC Login</a></li>
+ </ul>
+ </nav>
+ <%- end -%>
+ ERB
+ end
+ [200, { "Content-Type" => "text/html" }, [html]]
+ end
+
def oauth_callback(request)
response = oauth_client.exchange("authorization_code", code: request.params['code'])
if response.code == "200"