Login dengan Google UNTAN (OpenID Connect) yang dihubungkan ke akun aplikasi
- app/google_auth.py: authorization-code flow tanpa dependensi tambahan; klaim id_token diperiksa (iss, aud, exp, nonce, email_verified) dan email wajib domain GOOGLE_DOMAIN (bawaan untan.ac.id + subdomain). Aktif hanya bila GOOGLE_CLIENT_ID & SECRET terisi. - Akun Google ditautkan (pengguna.google_sub) oleh pemilik dari menu Akun, atau otomatis pada login pertama bila email sama dengan email akun / data induk mahasiswa. Tanpa pembuatan akun otomatis; satu Google satu akun; akun nonaktif ditolak. - Putus oleh pemilik mematikan tautan otomatis via email; putus oleh kaprodi (Data Master -> Dosen) mengizinkannya lagi. Login NIP/NPM + password tetap tersedia. - Uji: tests/uji_google.py (tiruan endpoint token Google). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
549fe53a11
commit
b09785fc62
@@ -28,5 +28,21 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% if google_aktif %}
|
||||
<div class="card mt-6" id="akun-google">
|
||||
{{ ui.card_header('Akun Google', sub='Masuk tanpa password memakai akun Google kampus (@' ~ google_domain ~ ' dan subdomainnya). Login NIP/NPM tetap bisa dipakai.', ikon='brand-google') }}
|
||||
<div class="card-body">
|
||||
{% if google_terhubung %}
|
||||
<p class="mb-4"><span class="badge bg-label-success me-2"><i class="icon-base ti tabler-circle-check icon-xs"></i> Terhubung</span>{{ email_akun }}</p>
|
||||
<form method="post" action="/akun/google/putus" onsubmit="return confirm('Putus akun Google? Anda tetap bisa masuk dengan NIP/NPM dan password.')">
|
||||
<button class="btn btn-label-danger" type="submit"><i class="icon-base ti tabler-unlink icon-sm me-1"></i>Putus akun Google</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="mb-4 text-body-secondary">Belum terhubung.{% if email_akun %} Email terdaftar: <b>{{ email_akun }}</b> — masuk dengan Google memakai email ini akan terhubung otomatis.{% endif %}</p>
|
||||
<a class="btn btn-primary" href="/auth/google?tujuan=hubung"><i class="icon-base ti tabler-brand-google icon-sm me-1"></i>Hubungkan akun Google</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div></div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -52,6 +52,12 @@
|
||||
{{ 'Buat Akun Kaprodi & Masuk' if mode == 'setup' else 'Masuk' }}
|
||||
</button>
|
||||
</form>
|
||||
{% if mode == 'login' and google_aktif() %}
|
||||
<div class="divider my-5"><div class="divider-text">atau</div></div>
|
||||
<a class="btn btn-label-secondary d-flex align-items-center justify-content-center gap-2 w-100" href="/auth/google">
|
||||
<i class="icon-base ti tabler-brand-google icon-md"></i>Masuk dengan Google UNTAN</a>
|
||||
<div class="form-text text-center mt-2">Akun Google kampus yang sudah dihubungkan di menu Akun, atau yang emailnya terdaftar di aplikasi.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mt-4">
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<td>
|
||||
<details>
|
||||
<summary class="fw-medium text-heading" style="cursor:pointer;list-style:none">{{ d.nama }}{% if d.role == 'kaprodi' %} <span class="badge bg-label-primary">Kaprodi</span>{% endif %}
|
||||
<small class="d-block text-body-secondary">{{ d.email or 'ubah nama/email…' }}</small></summary>
|
||||
<small class="d-block text-body-secondary">{{ d.email or 'ubah nama/email…' }}{% if d.google %} <span class="badge bg-label-success" title="Akun Google terhubung — bisa masuk dengan Google"><i class="icon-base ti tabler-brand-google icon-xs"></i> terhubung</span>{% endif %}</small></summary>
|
||||
<form method="post" action="/master/dosen/{{ d.id }}" class="d-flex flex-wrap gap-2 mt-2">
|
||||
<input class="form-control form-control-sm" name="nama" value="{{ d.nama }}" style="max-width:260px" aria-label="Nama">
|
||||
<input class="form-control form-control-sm" name="email" value="{{ d.email }}" placeholder="email" style="max-width:200px" aria-label="Email">
|
||||
@@ -53,6 +53,7 @@
|
||||
<form method="post" action="/master/dosen/{{ d.id }}" class="d-inline">
|
||||
{% if d.aktif %}
|
||||
<button class="btn btn-sm btn-text-secondary" type="submit" name="aksi" value="reset" title="Kembalikan password ke NIP"><i class="icon-base ti tabler-key icon-sm"></i></button>
|
||||
{% if d.google %}<button class="btn btn-sm btn-text-secondary" type="submit" name="aksi" value="putus_google" title="Putus tautan akun Google" onclick="return confirm('Putus tautan akun Google {{ d.nama }}?')"><i class="icon-base ti tabler-unlink icon-sm"></i></button>{% endif %}
|
||||
{% if d.id != user.id %}<button class="btn btn-sm btn-text-warning" type="submit" name="aksi" value="nonaktif" onclick="return confirm('Nonaktifkan {{ d.nama }}? Akun tidak bisa masuk; data lama tetap.')">Nonaktifkan</button>{% endif %}
|
||||
{% else %}
|
||||
<button class="btn btn-sm btn-text-success" type="submit" name="aksi" value="aktif">Aktifkan</button>
|
||||
|
||||
Reference in New Issue
Block a user