feat: Add cert renewing

This commit is contained in:
Nathan Woodburn 2025-03-31 13:40:42 +11:00
parent 0e71442339
commit 1c80c65b0f
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
8 changed files with 41 additions and 14 deletions

27
main.py
View File

@ -313,6 +313,33 @@ def publish():
response.set_cookie('auth', '', expires=0)
return response
@app.route('/renew')
def renew():
if 'auth' not in request.cookies:
return redirect('/')
auth = request.cookies['auth']
for i in cookies:
if i['cookie'] == auth:
# Load site content
if os.path.isfile(f'sites/{i["name"]}.json'):
with open(f'sites/{i["name"]}.json') as file:
data = json.load(file)
def regenerate_ssl_and_write_nginx():
tlsa = nginx.generate_ssl(i['name'])
data['tlsa'] = tlsa
with open(f'sites/{i["name"]}.json', 'w') as file:
json.dump(data, file)
nginx.write_nginx_conf(i['name'])
threading.Thread(target=regenerate_ssl_and_write_nginx).start()
return redirect('/publishing')
response = make_response(redirect('/'))
response.set_cookie('auth', '', expires=0)
return response
@app.route('/nostr')
def nostr():
if 'auth' not in request.cookies:

View File

@ -10,10 +10,10 @@
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">
<meta property="og:title" content="HNS Links">
<meta name="description" content="Create a links page for your domain">
<meta property="og:description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<meta name="twitter:description" content="Create a links page for your domain">
<meta name="description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">

File diff suppressed because one or more lines are too long

View File

@ -10,10 +10,10 @@
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">
<meta property="og:title" content="HNS Links">
<meta name="description" content="Create a links page for your domain">
<meta property="og:description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<meta name="twitter:description" content="Create a links page for your domain">
<meta name="description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<script type="application/ld+json">
{
"@context": "http://schema.org",

View File

@ -10,10 +10,10 @@
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">
<meta property="og:title" content="HNS Links">
<meta name="description" content="Create a links page for your domain">
<meta property="og:description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<meta name="twitter:description" content="Create a links page for your domain">
<meta name="description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">

View File

@ -10,10 +10,10 @@
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">
<meta property="og:title" content="HNS Links">
<meta name="description" content="Create a links page for your domain">
<meta property="og:description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<meta name="twitter:description" content="Create a links page for your domain">
<meta name="description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">

View File

@ -10,10 +10,10 @@
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">
<meta property="og:title" content="HNS Links">
<meta name="description" content="Create a links page for your domain">
<meta property="og:description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<meta name="twitter:description" content="Create a links page for your domain">
<meta name="description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
@ -93,7 +93,7 @@
<div>
<p style="display: inline-block;">Text</p><input class="form-control form-control-color" type="color" style="display: inline-block;margin-left: 25px;height: 2em;" name="btn_fg" value="{{btn_fg}}">
</div>
</div><input class="btn btn-primary" type="submit" value="Save" style="margin-right: 20px;"><a class="btn btn-primary" role="button" href="/publish">Publish</a>
</div><input class="btn btn-primary" type="submit" value="Save" style="margin: 10px;margin-right: 20px;"><a class="btn btn-primary" role="button" href="/publish" style="margin: 10px;">Publish</a><a class="btn btn-primary" role="button" href="/renew" style="margin: 10px;">Refresh SSL cert</a>
</form>
</div>
<div class="col-md-6" style="text-align: center;">{{preview|safe}}<a class="btn btn-primary" role="button" href="/nostr" style="margin-top: 1em;">Link Nostr</a></div>

View File

@ -10,10 +10,10 @@
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">
<meta property="og:title" content="HNS Links">
<meta name="description" content="Create a links page for your domain">
<meta property="og:description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<meta name="twitter:description" content="Create a links page for your domain">
<meta name="description" content="Create a links page for your domain">
<meta property="og:image" content="https://links.hns.au/assets/img/dashboard.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">