Add social auth Github + login page

This commit is contained in:
2024-10-05 14:16:08 +02:00
parent d7f0d2a7f2
commit 63897fb7b0
14 changed files with 210 additions and 55 deletions
+18 -13
View File
@@ -41,8 +41,8 @@
<nav class="navbar navbar-expand-lg bg-primary" data-bs-theme="dark">
<div class="container-fluid">
<v-btn color="navbar-brand" text @click="lock_me">
<v-icon small class="mr-2">mdi-lock</v-icon>
<v-btn outlined dark text @click="lock_me">
<v-icon small color="white" class="mr-2">mdi-lock</v-icon>
{% trans "Lock" %}
</v-btn>
@@ -61,21 +61,19 @@
<li class="nav-item">
<router-link class="nav-link" to="/EncryptionTesting">{% trans "Encryption" %}</router-link>
</li>
{% if request.user.is_superuser %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{% trans "More" %}</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{% trans "More" %}</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="{% url 'users:logout' %}">{% trans "Logout" %}</a>
{% if request.user.is_superuser %}
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/admin/">{% trans "Admin" %}</a>
</div>
</li>
{% endif %}
{% endif %}
</div>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-sm-2" type="search" placeholder="Search">
<input class="form-control me-sm-2" type="search" placeholder="Search" v-model="search">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
@@ -83,10 +81,17 @@
</nav>
<v-container class="container-xs">
<div class="card bg-danger mt-4 pt-2 ps-lg-2 d-flex" v-if="!ready">
<h5 class="card-header flex-grow-1 flex-shrink-1 text-center">{% trans "Cannot load the application. Webcrypto must be enabled" %}</h5>
</div>
<Loading @update_key="update_key" v-if="locked"></Loading>
<template v-if="!locked">
<router-view></router-view>
</template>
</v-container>
</div>
+101
View File
@@ -0,0 +1,101 @@
{% load i18n static %}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %}</title>
<link rel="shortcut icon" href="{% static 'img/favicon.png' %}">
<script src="{% static "vue/index.js" %}"></script>
<script src="{% static "sweetalert2/index" %}"></script>
<script src="{% static "vue-resource/index" %}"></script>
<script src="{% static "js.cookie.min/index.js" %}"></script>
<script src="{% static "vue-router/index.js" %}"></script>
<link href="{% static "bootstrap.min/index.css" %}" rel="stylesheet">
<script src="{% static "bootstrap.bundle.min/index.js" %}"></script>
<link href="{% static "bootswatch.min.css/index.css" %}" rel="stylesheet">
<script src="{% url 'reverse_js' %}" type="text/javascript"></script>
<link href="{% static "vuetify.min/index.css" %}" rel="stylesheet">
<script src="{% static "vuetify/index.js" %}"></script>
<script src="{% static "vuex/index.js" %}"></script>
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
<link href="{% static "jetbrains-mono/index" %}">
<style>
.font {
font-family: 'JetBrains Mono', sans-serif;
}
</style>
</head>
<body>
<v-app class="font">
<div id="main" data-app>
<v-content>
<v-container class="container-xs">
<v-row justify="center">
<v-dialog v-model="dialog" persistent max-width="290">
<v-card>
<v-card-title class="text-h5">
{% trans "Login" %}
</v-card-title>
<v-card-text>
{% trans "Select login option" %}
<v-list-item>
<v-list-item-content>
<v-btn tile color="primary" dark class="mb-2" href="{% url 'social:begin' 'github' %}">
{% trans "Github" %}
</v-btn>
</v-list-item-content>
</v-list-item>
</v-card-text>
</v-card>
</v-dialog>
</v-row>
</v-container>
</v-content>
</div>
</v-app>
<script type="text/javascript">
{% include 'scripts.js' %}
</script>
{% for name, path in templates.items %}
<script type="text/x-template" id="{{ name }}">
{% include path %}
</script>
{% endfor %}
<script type="text/javascript">
{% include "vue/login.js" %}
</script>
<script type="text/javascript">
function refresh_csrftoken() {
var csrftoken = Cookies.get('csrftoken');
Vue.http.headers.common['X-CSRFTOKEN'] = csrftoken;
}
refresh_csrftoken();
</script>
</body>
</html>
+6 -7
View File
@@ -35,7 +35,8 @@ const approuter = new Vue({
el: "#main",
data: {
uuid: "{{ user_settings.id }}",
ready: null,
ready: false,
search: '',
},
computed: {
@@ -50,8 +51,6 @@ const approuter = new Vue({
Swal.fire({title: "{{_('The application cannot be launched. Webcrypto is not available.<br><br>Try another browser!') | escapejs}}", icon: "error", showConfirmButton: false})
this.ready = false
} else {
// Try to generate a random keyPair and encrypting stuff before accepting the client
@@ -65,8 +64,6 @@ const approuter = new Vue({
Swal.fire({title: "{{_('An error occured during testing Webcrypto. Please use a compatible browser.') | escapejs}}", icon: "error", showConfirmButton: false})
this.ready = false
}
}
@@ -99,8 +96,8 @@ const approuter = new Vue({
await this.$http.post(
Urls["users:keys"](),
{
privateKey: await this.wrapKey(this.keyPair.privateKey, aes_key, iv_private),
publicKey: await this.wrapKey(this.keyPair.publicKey, aes_key, iv_public),
privateKey: await this.wrapKey(keyPair.privateKey, aes_key, iv_private),
publicKey: await this.wrapKey(keyPair.publicKey, aes_key, iv_public),
}
)
@@ -118,6 +115,8 @@ const approuter = new Vue({
Swal.fire({title: "{{_('Error during unwrapping of private key.<br><br>Maybe your password is wrong?') | escapejs}}", icon: "error", showConfirmButton: false})
console.error(err)
}
},
+17
View File
@@ -0,0 +1,17 @@
{% include "vue/plugins.js" %}
Vue.config.devtools = true
Vue.use(VueRouter)
Vue.use(Vuex)
Vue.use(EncryptionPlugin)
Vue.config.delimiters = ["[[", "]]"];
const approuter = new Vue({
vuetify: new Vuetify(),
el: "#main",
data: {
dialog: true,
},
})