provide oauth variables

This commit is contained in:
deflax 2024-04-06 15:18:09 +03:00
parent 236b2ebdcd
commit 04833ff7e0
4 changed files with 37 additions and 8 deletions

View file

@ -20,3 +20,32 @@ class Config(object):
MAIL_USE_TLS = f"{os.getenv('MAIL_USE_TLS')}"
ADMIN_MAIL = f"{os.getenv('ADMIN_MAIL')}"
ITEMS_PER_PAGE = f"{os.getenv('ITEMS_PER_PAGE')}"
OAUTH2_PROVIDERS = {
# Google OAuth 2.0 documentation:
# https://developers.google.com/identity/protocols/oauth2/web-server#httprest
'google': {
'client_id': os.environ.get('GOOGLE_CLIENT_ID'),
'client_secret': os.environ.get('GOOGLE_CLIENT_SECRET'),
'authorize_url': 'https://accounts.google.com/o/oauth2/auth',
'token_url': 'https://accounts.google.com/o/oauth2/token',
'userinfo': {
'url': 'https://www.googleapis.com/oauth2/v3/userinfo',
'email': lambda json: json['email'],
},
'scopes': ['https://www.googleapis.com/auth/userinfo.email'],
},
# GitHub OAuth 2.0 documentation:
# https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps
'github': {
'client_id': os.environ.get('GITHUB_CLIENT_ID'),
'client_secret': os.environ.get('GITHUB_CLIENT_SECRET'),
'authorize_url': 'https://github.com/login/oauth/authorize',
'token_url': 'https://github.com/login/oauth/access_token',
'userinfo': {
'url': 'https://api.github.com/user/emails',
'email': lambda json: json[0]['email'],
},
'scopes': ['user:email'],
}
}

View file

@ -4,7 +4,7 @@
{% import "bootstrap/fixes.html" as fixes %}
{% import "bootstrap/utils.html" as util %}
{% block title %}Cloud Builder - Datapoint.bg{% endblock %}
{% block title %}ForestNet{% endblock %}
{% block head %}
{{ super() }}

View file

@ -39,13 +39,7 @@
<script type="text/javascript">
$(document).ready(function() {
$('#newsmenu').load('https://www.datapoint.bg/news/latest');
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#livesupport').load('https://www.datapoint.bg/kiwi/');
$('#newsmenu').load('https://forest.deflax.net/news/latest');
});
</script>
{% endblock %}
@ -75,6 +69,8 @@
<div class="panel-body">
<br /><br /><br />
{% if not current_user.is_authenticated %}
<div class="form">
<form class="register-form" actoion="{{ url_for('auth.register') }}" method="POST">
<input type="text" placeholder="name"/>
@ -91,6 +87,7 @@
<p class="message">Not registered? <a href="#">Create an account</a></p>
</form>
</div>
{% endif %}
</div>
</div>
</div>

View file

@ -14,6 +14,9 @@ POSTGRES_DB=forest_prod
PGADMIN_DEFAULT_EMAIL=mail@example.com
PGADMIN_DEFAULT_PASSWORD=hackme
GOOGLE_CLIENT_ID=changeme
GOOGLE_CLIENT_SECRET=changeme
MAIL_SENDER=mail@example.com
MAIL_SUBJECT_PREFIX=ForestNet
MAIL_SERVER=smtp.gmail.com