aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/templates
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-07 07:58:09 +0300
committerFrederick Muriuki Muriithi2023-08-07 09:26:12 +0300
commit6d9c61dc0072b96b12153e64940b465306f25bfb (patch)
treea4957c7967e56b4527c1e926744a65a3326935ce /gn_auth/templates
parent6ab6d46ab4b1611ed72bdbce85cf9324ce69b305 (diff)
downloadgn-auth-6d9c61dc0072b96b12153e64940b465306f25bfb.tar.gz
Change imports to new unified db module.
Diffstat (limited to 'gn_auth/templates')
-rw-r--r--gn_auth/templates/admin/dashboard.html24
-rw-r--r--gn_auth/templates/admin/list-oauth2-clients.html56
-rw-r--r--gn_auth/templates/admin/login.html32
-rw-r--r--gn_auth/templates/admin/register-client.html78
-rw-r--r--gn_auth/templates/admin/registered-client.html21
-rw-r--r--gn_auth/templates/admin/view-oauth2-client.html75
-rw-r--r--gn_auth/templates/base.html24
-rw-r--r--gn_auth/templates/common-macros.html7
-rw-r--r--gn_auth/templates/oauth2/authorise-user.html48
-rw-r--r--gn_auth/templates/oauth2/oauth2_error.html16
10 files changed, 381 insertions, 0 deletions
diff --git a/gn_auth/templates/admin/dashboard.html b/gn_auth/templates/admin/dashboard.html
new file mode 100644
index 0000000..7798022
--- /dev/null
+++ b/gn_auth/templates/admin/dashboard.html
@@ -0,0 +1,24 @@
+{%extends "base.html"%}
+
+{%block title%}Genenetwork3: Admin Dashboard{%endblock%}
+
+{%block pagetitle%}Admin Dashboard{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+<ul class="nav">
+ <li>
+ <a href="{{url_for('oauth2.admin.register_client')}}"
+ title="Register a new OAuth2 client.">Register OAuth2 Client</a>
+ </li>
+ <li>
+ <a href="{{url_for('oauth2.admin.list_clients')}}"
+ title="List OAuth2 clients.">List OAuth2 Client</a>
+ </li>
+ <li>
+ <a href="{{url_for('oauth2.admin.logout')}}"
+ title="Log out of the system.">Logout</a>
+ </li>
+</ul>
+{%endblock%}
diff --git a/gn_auth/templates/admin/list-oauth2-clients.html b/gn_auth/templates/admin/list-oauth2-clients.html
new file mode 100644
index 0000000..0104f0d
--- /dev/null
+++ b/gn_auth/templates/admin/list-oauth2-clients.html
@@ -0,0 +1,56 @@
+{%extends "base.html"%}
+
+{%block title%}Genenetwork3: OAuth2 Clients{%endblock%}
+
+{%block pagetitle%}OAuth2 Clients{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+<table class="table table-hover table-striped cell-border no-footer">
+ <caption>List of registered OAuth2 clients</caption>
+ <thead>
+ <tr>
+ <th>Client ID</th>
+ <th>Client Name</th>
+ <th>Default Redirect URI</th>
+ <th>Owner</th>
+ <th colspan="2">Actions</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {%for client in clients%}
+ <tr>
+ <td>{{client.client_id}}</td>
+ <td>{{client.client_metadata.client_name}}</td>
+ <td>{{client.client_metadata.default_redirect_uri}}</td>
+ <td>{{client.user.name}} ({{client.user.email}})</td>
+ <td>
+ <a href="{{url_for('oauth2.admin.view_client', client_id=client.client_id)}}"
+ title"View/Edit client {{client.client_metadata.client_name}}"
+ class="btn btn-info">
+ View/Edit
+ </a>
+ </td>
+ <td>
+ <form id="frm:delete:{{client.client_id}}"
+ action="{{url_for('oauth2.admin.delete_client')}}"
+ method="POST">
+ <input type="hidden" name="client_id" value="{{client.client_id}}" />
+ <input type="submit" value="Delete"
+ title"Delete client {{client.client_metadata.client_name}}"
+ class="btn btn-danger" />
+ </form>
+ </td>
+ </tr>
+ {%else%}
+ <tr>
+ <td colspan="4" style="text-align: center;">
+ No registered OAuth2 clients!
+ </td>
+ </tr>
+ {%endfor%}
+ </tbody>
+</table>
+{%endblock%}
diff --git a/gn_auth/templates/admin/login.html b/gn_auth/templates/admin/login.html
new file mode 100644
index 0000000..ac217ab
--- /dev/null
+++ b/gn_auth/templates/admin/login.html
@@ -0,0 +1,32 @@
+{%extends "base.html"%}
+
+{%block title%}Log in to Genenetwork3{%endblock%}
+
+{%block pagetitle%}Admin Log In{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+<form method="POST" action="{{url_for('oauth2.admin.login')}}">
+
+ <fieldset>
+ <legend>User Credentials</legend>
+
+ <input name="next_uri" type="hidden" value={{next_uri}}>
+
+ <fieldset class="form-group">
+ <label for="txt:email" class="form-label">Email Address</label>
+ <input name="email" type="email" id="txt:email" required="required"
+ placeholder="your@email.address" class="form-control" />
+ </fieldset>
+
+ <fieldset class="form-group">
+ <label for="txt:password" class="form-label">Password</label>
+ <input name="password" type="password" id="txt:password"
+ required="required" class="form-control" />
+ </fieldset>
+ </fieldset>
+
+ <input type="submit" value="log in" class="btn btn-primary" />
+</form>
+{%endblock%}
diff --git a/gn_auth/templates/admin/register-client.html b/gn_auth/templates/admin/register-client.html
new file mode 100644
index 0000000..daac977
--- /dev/null
+++ b/gn_auth/templates/admin/register-client.html
@@ -0,0 +1,78 @@
+{%extends "base.html"%}
+
+{%block title%}Genenetwork3: Register OAuth2 Client{%endblock%}
+
+{%block pagetitle%}Register OAuth2 Client{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+<form method="POST" action="{{url_for('oauth2.admin.register_client')}}">
+
+ <fieldset>
+ <legend>Select client scope</legend>
+
+ {%for scp in scope%}
+ <input name="scope[]" id="chk:{{scp}}"type="checkbox" value="{{scp}}"
+ {%if scp=="profile"%}checked="checked"{%endif%} />
+ <label for="chk:{{scp}}">{{scp}}</label><br />
+ {%endfor%}
+
+ </fieldset>
+
+ <fieldset>
+ <legend>Basic OAuth2 client information</legend>
+
+
+ <label for="txt:client-name">Client name</label>
+ <input name="client_name" type="text" id="txt:client-name"
+ required="required" />
+ <br /><br />
+
+ <label for="txt:redirect-uri">Redirect URI</label>
+ <input name="redirect_uri" type="text" id="txt:redirect-uri"
+ required="required" />
+ <br /><br />
+
+ <label for="txt:other-redirect-uris">
+ Other redirect URIs (Enter one URI per line)</label>
+ <br />
+ <textarea name="other_redirect_uris" id="txt:other-redirect-uris"
+ cols="80" rows="10"
+ title="Enter one URI per line."></textarea>
+ <br /><br />
+ <fieldset>
+ <legend>Supported grant types</legend>
+ <input name="grants[]"
+ type="checkbox"
+ value="authorization_code"
+ id="chk:authorization-code"
+ checked="checked" />
+ <label for="chk:authorization-code">Authorization Code</label>
+ <br /><br />
+
+ <input name="grants[]"
+ type="checkbox"
+ value="refresh_token"
+ id="chk:refresh-token" />
+ <label for="chk:refresh-token">Refresh Token</label>
+ </fieldset>
+ </fieldset>
+
+ <fieldset>
+ <legend>User information</legend>
+
+ <p>The user to register this client for</p>
+ <select name="user" required="required">
+ {%for user in users%}
+ <option value="{{user.user_id}}"
+ {%if user.user_id==current_user.user_id%}
+ selected="selected"
+ {%endif%}>{{user.name}} ({{user.email}})</option>
+ {%endfor%}
+ </select>
+ </fieldset>
+
+ <input type="submit" value="register client" />
+</form>
+{%endblock%}
diff --git a/gn_auth/templates/admin/registered-client.html b/gn_auth/templates/admin/registered-client.html
new file mode 100644
index 0000000..5c46f4d
--- /dev/null
+++ b/gn_auth/templates/admin/registered-client.html
@@ -0,0 +1,21 @@
+{%extends "base.html"%}
+
+{%block title%}Genenetwork3: Register OAuth2 Client{%endblock%}
+
+{%block pagetitle%}Register OAuth2 Client{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+<p>Client has been registered successfully.</p>
+
+<p>Please save the following client details somewhere. There is no way to
+ retrieve the the <strong>CLIENT_SECRET</strong> once you leave this page.</p>
+
+<dl>
+ <dt>CLIENT_ID</dt>
+ <dd>{{client.client_id}}</dd>
+ <dt>CLIENT_SECRET</dt>
+ <dd>{{client_secret}}</dd>
+</dl>
+{%endblock%}
diff --git a/gn_auth/templates/admin/view-oauth2-client.html b/gn_auth/templates/admin/view-oauth2-client.html
new file mode 100644
index 0000000..b90428d
--- /dev/null
+++ b/gn_auth/templates/admin/view-oauth2-client.html
@@ -0,0 +1,75 @@
+{%extends "base.html"%}
+
+{%block title%}Genenetwork3: View OAuth2 Client{%endblock%}
+
+{%block pagetitle%}View OAuth2 Client{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+{%if client.is_nothing()%}
+<p>No such client</p>
+{%else%}
+{%set client = client.value%}
+<form method="POST" action="{{url_for('oauth2.admin.edit_client')}}">
+ <legend>View/Edit Oauth2 Client</legend>
+ <input type="hidden" name="client_id" value="{{client.client_id}}" />
+ <div>
+ <p><strong>Client ID: <strong> {{client.client_id}}</p>
+ <p><strong>Client Name: <strong> {{client.client_metadata.client_name}}</p>
+ </div>
+ <fieldset>
+ <legend>Scope</legend>
+ {%for scp in scope%}
+ <input name="scope[]" id="chk:{{scp}}" type="checkbox" value="{{scp}}"
+ {%if scp in client.client_metadata.scope%}
+ checked="checked"
+ {%endif%} />
+ <label for="chk:{{scp}}">{{scp}}</label><br />
+ {%endfor%}
+ </fieldset>
+
+ <fieldset>
+ <legend>Redirect URIs</legend>
+ <label for="txt:default-redirect-uri">Default Redirect URI</label>
+ <br />
+ <input type="text" name="default_redirect_uri" id="txt:default-redirect-uri"
+ value="{{client.client_metadata.default_redirect_uri}}"
+ required="required">
+ <br /><br />
+
+ <label for="txta:other-redirect-uris">Other Redirect URIs</label>
+ <br />
+ <textarea id="txta:other-redirect-uris"
+ name="other_redirect_uris"
+ cols="80" rows="10"
+ title="Enter one URI per line."
+ >{{"\r\n".join(client.client_metadata.redirect_uris)}}</textarea>
+ </fieldset>
+
+ <fieldset>
+ <legend>Grants</legend>
+ <input name="grants[]"
+ type="checkbox"
+ value="authorization_code"
+ id="chk:authorization-code"
+ {%if "authorization_code" in client.client_metadata.grant_types%}
+ checked="checked"
+ {%endif%} />
+ <label for="chk:authorization-code">Authorization Code</label>
+ <br /><br />
+
+ <input name="grants[]"
+ type="checkbox"
+ value="refresh_token"
+ id="chk:refresh-token"
+ {%if "refresh_token" in client.client_metadata.grant_types%}
+ checked="checked"
+ {%endif%} />
+ <label for="chk:refresh-token">Refresh Token</label>
+ </fieldset>
+
+ <input type="submit" value="update client" />
+</form>
+{%endif%}
+{%endblock%}
diff --git a/gn_auth/templates/base.html b/gn_auth/templates/base.html
new file mode 100644
index 0000000..db08545
--- /dev/null
+++ b/gn_auth/templates/base.html
@@ -0,0 +1,24 @@
+{% from "common-macros.html" import flash_messages%}
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+
+ <title>Genenetwork 3: {%block title%}{%endblock%}</title>
+
+ <link rel="stylesheet" type="text/css"
+ href="https://genenetwork.org/static/new/css/bootstrap-custom.css" />
+ <link rel="stylesheet" type="text/css" href="/static/css/styles.css" />
+ {%block css%}{%endblock%}
+ </head>
+
+ <body>
+ <h1>Genenetwork3: {%block pagetitle%}{%endblock%}</h1>
+
+ <div class="container">
+ {%block content%}{%endblock%}
+ </div>
+ {%block js%}{%endblock%}
+ <body>
+</html>
diff --git a/gn_auth/templates/common-macros.html b/gn_auth/templates/common-macros.html
new file mode 100644
index 0000000..1d9f302
--- /dev/null
+++ b/gn_auth/templates/common-macros.html
@@ -0,0 +1,7 @@
+{%macro flash_messages()%}
+<div class="alert-messages">
+ {%for category,message in get_flashed_messages(with_categories=true)%}
+ <div class="alert {{category}}" role="alert">{{message}}</div>
+ {%endfor%}
+</div>
+{%endmacro%}
diff --git a/gn_auth/templates/oauth2/authorise-user.html b/gn_auth/templates/oauth2/authorise-user.html
new file mode 100644
index 0000000..b9284e5
--- /dev/null
+++ b/gn_auth/templates/oauth2/authorise-user.html
@@ -0,0 +1,48 @@
+{%extends "base.html"%}
+
+{%block title%}Authorise User{%endblock%}
+
+{%block pagetitle%}Authenticate to the API Server{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+<form method="POST" action="{{url_for('oauth2.auth.authorise')}}">
+ <input type="hidden" name="response_type" value="{{response_type}}" />
+ <input type="hidden" name="scope" value="{{scope | join(' ')}}" />
+ <input type="hidden" name="client_id" value="{{client.client_id}}" />
+ <p>
+ You are authorising "{{client.client_metadata.client_name}}" to access
+ Genenetwork 3 with the following scope:
+ </p>
+ <fieldset>
+ <legend>Scope</legend>
+ {%for scp in scope%}
+ <div class="checkbox disabled">
+ <label for="scope:{{scp}}">
+ <input id="scope:{{scp}}" type="checkbox" name="scope[]" value="{{scp}}"
+ checked="checked" disabled="disabled" />
+ {{scp}}
+ </label>
+ </div>
+ {%endfor%}
+ </fieldset>
+
+ <fieldset>
+ <legend>User Credentials</legend>
+ <fieldset class="form-group">
+ <label for="user:email" class="form-label">Email</label>
+ <input type="email" name="user:email" id="user:email" required="required"
+ class="form-control"/>
+ </fieldset>
+
+ <fieldset class="form-group">
+ <label for="user:password" class="form-label">Password</label>
+ <input type="password" name="user:password" id="user:password"
+ required="required" class="form-control" />
+ </fieldset>
+ </fieldset>
+
+ <input type="submit" value="authorise" class="btn btn-primary" />
+</form>
+{%endblock%}
diff --git a/gn_auth/templates/oauth2/oauth2_error.html b/gn_auth/templates/oauth2/oauth2_error.html
new file mode 100644
index 0000000..ec9a500
--- /dev/null
+++ b/gn_auth/templates/oauth2/oauth2_error.html
@@ -0,0 +1,16 @@
+{%extends "base.html"%}
+
+{%block title%}OAuth2 Error{%endblock%}
+
+{%block pagetitle%}Error: {{error.status_code}}{%endblock%}
+
+{%block content%}
+{{flash_messages()}}
+
+There was an error trying to fulfill your request:
+
+<p>
+ <strong>{{error.error}}</strong>:
+ {{error.description}}
+</p>
+{%endblock%}