Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ env/
tmp/

db.sqlite3
source/app/conf/development/.env
source/app/conf/production/.env
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ name = "pypi"
[packages]
Django = "==4.1.4"
"django-bootstrap4" = "==22.3"

pangea-sdk = "*"
django-environ = "*"
264 changes: 263 additions & 1 deletion Pipfile.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions source/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from django.views.generic import View, FormView
from django.conf import settings

from pangea.config import PangeaConfig
from pangea.services import Audit

from .utils import (
send_activation_email, send_reset_password_email, send_forgotten_username_email, send_activation_change_email,
)
Expand Down Expand Up @@ -76,6 +79,11 @@ def form_valid(self, form):

login(request, form.user_cache)

if request.user.is_authenticated:
config = PangeaConfig(domain=settings.PANGEA_DOMAIN)
audit = Audit(settings.PANGEA_TOKEN, config=config)
audit.log("User logged into the app!")

redirect_to = request.POST.get(REDIRECT_FIELD_NAME, request.GET.get(REDIRECT_FIELD_NAME))
url_is_safe = is_safe_url(redirect_to, allowed_hosts=request.get_host(), require_https=request.is_secure())

Expand Down
2 changes: 2 additions & 0 deletions source/app/conf/development/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PANGEA_DOMAIN=
PANGEA_TOKEN=

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a separate token for each service and have the service scope in the var name

9 changes: 9 additions & 0 deletions source/app/conf/development/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import warnings
from django.utils.translation import gettext_lazy as _
from os.path import dirname
import environ

env = environ.Env()
environ.Env.read_env()

warnings.simplefilter('error', DeprecationWarning)

Expand All @@ -26,6 +30,7 @@

# Vendor apps
'bootstrap4',
'pangea',

# Application apps
'main',
Expand Down Expand Up @@ -100,6 +105,10 @@
LOGIN_URL = 'accounts:log_in'
USE_REMEMBER_ME = True

#Pangea
PANGEA_DOMAIN = env('PANGEA_DOMAIN')
PANGEA_TOKEN = env('PANGEA_TOKEN')

RESTORE_PASSWORD_VIA_EMAIL_OR_USERNAME = False
ENABLE_ACTIVATION_AFTER_EMAIL_CHANGE = True

Expand Down
2 changes: 2 additions & 0 deletions source/app/conf/production/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PANGEA_DOMAIN=
PANGEA_TOKEN=