add "domain" option to config.json
add usages of the "domain" option
This commit is contained in:
parent
a1e25a9bdc
commit
c600c59af8
4 changed files with 18 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
|||
"MNT": "YOUR-MNT", // your MNT tag
|
||||
"listen": "0.0.0.0",
|
||||
"port": 8042,
|
||||
"domain": "example.org", // domain to use for kioubit verification service
|
||||
"flask-secret-key": "<secret-please-replace>", // secret key for session cookies
|
||||
"flask-debug": false, // optional; default false
|
||||
"flask-template-dir": "../frontend/" // optional; default "../frontend"
|
||||
|
|
|
@ -35,9 +35,10 @@ class AuthVerifyer ():
|
|||
#, base64.b64decode(params), "sha512")
|
||||
h = SHA512.new()
|
||||
h.update(base64.b64decode(params))
|
||||
print(h.hexdigest())
|
||||
#print(h.hexdigest())
|
||||
verifier = DSS.new(self.pubkey, 'fips-186-3')
|
||||
print(verifier.verify(h, signature))
|
||||
valid = verifier.verify(h, signature)
|
||||
return valid
|
||||
|
||||
if __name__ == "__main__":
|
||||
example_com_verifier = AuthVerifyer("example.com")
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from flask import Flask, Response, redirect, render_template, request, session, abort
|
||||
import json, os
|
||||
import json, os, base64
|
||||
from functools import wraps
|
||||
|
||||
import kioubit_verify
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
class Config (dict):
|
||||
|
@ -40,6 +42,7 @@ class Config (dict):
|
|||
print(self._config)
|
||||
|
||||
config = Config()
|
||||
|
||||
def auth_required():
|
||||
def wrapper(f):
|
||||
@wraps(f)
|
||||
|
@ -52,6 +55,15 @@ def auth_required():
|
|||
return wrapper
|
||||
|
||||
|
||||
kverifyer = kioubit_verify.AuthVerifyer(config["domain"])
|
||||
@app.route("/api/auth/kverify", methods=["GET", "POST"])
|
||||
def kioubit_auth():
|
||||
params = request.args["params"]
|
||||
signature = request.args["signature"]
|
||||
print(base64.b64decode(params))
|
||||
return str(kverifyer.verify(params, signature))
|
||||
|
||||
|
||||
@app.route("/login",methods=["GET","POST"])
|
||||
def login():
|
||||
if request.method == "GET":
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<form action="https://dn42.g-load.eu/auth/">
|
||||
<link rel="stylesheet" href="https://dn42.g-load.eu/auth/assets/button-font/auth.css">
|
||||
<input type="hidden" id="return" name="return" value="{{return_addr}}">
|
||||
<input type="hidden" id="return" name="return" value='{{"http://"+config["domain"]+"/api/auth/kverify"}}'>
|
||||
<button type="submit" class="kioubit-btn kioubit-btn-primary kioubit-btn-dark kioubit-btn-main">
|
||||
<span class="icon-kioubit-auth"></span>Authenticate with Kioubit.dn42
|
||||
</button>
|
||||
|
|
Loading…
Add table
Reference in a new issue