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
|
"MNT": "YOUR-MNT", // your MNT tag
|
||||||
"listen": "0.0.0.0",
|
"listen": "0.0.0.0",
|
||||||
"port": 8042,
|
"port": 8042,
|
||||||
|
"domain": "example.org", // domain to use for kioubit verification service
|
||||||
"flask-secret-key": "<secret-please-replace>", // secret key for session cookies
|
"flask-secret-key": "<secret-please-replace>", // secret key for session cookies
|
||||||
"flask-debug": false, // optional; default false
|
"flask-debug": false, // optional; default false
|
||||||
"flask-template-dir": "../frontend/" // optional; default "../frontend"
|
"flask-template-dir": "../frontend/" // optional; default "../frontend"
|
||||||
|
|
|
@ -35,9 +35,10 @@ class AuthVerifyer ():
|
||||||
#, base64.b64decode(params), "sha512")
|
#, base64.b64decode(params), "sha512")
|
||||||
h = SHA512.new()
|
h = SHA512.new()
|
||||||
h.update(base64.b64decode(params))
|
h.update(base64.b64decode(params))
|
||||||
print(h.hexdigest())
|
#print(h.hexdigest())
|
||||||
verifier = DSS.new(self.pubkey, 'fips-186-3')
|
verifier = DSS.new(self.pubkey, 'fips-186-3')
|
||||||
print(verifier.verify(h, signature))
|
valid = verifier.verify(h, signature)
|
||||||
|
return valid
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
example_com_verifier = AuthVerifyer("example.com")
|
example_com_verifier = AuthVerifyer("example.com")
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
from flask import Flask, Response, redirect, render_template, request, session, abort
|
from flask import Flask, Response, redirect, render_template, request, session, abort
|
||||||
import json, os
|
import json, os, base64
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
import kioubit_verify
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
class Config (dict):
|
class Config (dict):
|
||||||
|
@ -40,6 +42,7 @@ class Config (dict):
|
||||||
print(self._config)
|
print(self._config)
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
|
||||||
def auth_required():
|
def auth_required():
|
||||||
def wrapper(f):
|
def wrapper(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
|
@ -52,6 +55,15 @@ def auth_required():
|
||||||
return wrapper
|
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"])
|
@app.route("/login",methods=["GET","POST"])
|
||||||
def login():
|
def login():
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<form action="https://dn42.g-load.eu/auth/">
|
<form action="https://dn42.g-load.eu/auth/">
|
||||||
<link rel="stylesheet" href="https://dn42.g-load.eu/auth/assets/button-font/auth.css">
|
<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">
|
<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
|
<span class="icon-kioubit-auth"></span>Authenticate with Kioubit.dn42
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue