Skip to content

Commit

Permalink
make SSL an env setting instead of profile_urls, built on top of sche…
Browse files Browse the repository at this point in the history
…me + host
  • Loading branch information
boogheta committed Jul 24, 2024
1 parent 5ab5c96 commit c6797b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
12 changes: 2 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
RESIN_DEBUG=True # change that !
RESIN_SECRET=secret # change that !
RESIN_HOST=example.com # change that !
RESIN_SSL=True # change that !
RESIN_DOCKER_CONTAINER=django # change that, maybe?
RESIN_EMAIL_FROM=[email protected] # change that !

RESIN_EDIT_PROFILE_URL=http://example.com/edit-profile # change that ! -> URL to edit profile
# users will be redirected to http://example.com/edit-profile?uid=uid&token=token
# when they click on the link in the modification request email
# this page should contain the resin-formulaire component

RESIN_PROFILE_URL=http://example.com/member # change that ! -> base URL for profiles
# users will be sent to http://example.com/member/[slug]
# when they click on the link in the registration confirmation email

## Examples are default value if omitted ##

# RESIN_EMAIL_HOST=localhost
Expand All @@ -27,4 +19,4 @@ RESIN_PROFILE_URL=http://example.com/member # change that ! -> base URL for prof
## Settings specific to SSL/TLS on SMTP

# RESIN_EMAIL_SSL_CERTFILE = "path/to/file" # needed in case of self-signed certificate
# RESIN_EMAIL_SSL_KEYFILE = "path/to/file" # needed in case of self-signed certificate
# RESIN_EMAIL_SSL_KEYFILE = "path/to/file" # needed in case of self-signed certificate
2 changes: 1 addition & 1 deletion annuaire/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def perform_create(self, serializer):
)
)
admin_link = (
"https://"
settings.RESIN_SCHEME + "://"
+ settings.RESIN_HOST
+ reverse("admin:annuaire_member_change", args=[serializer.instance.pk])
)
Expand Down
8 changes: 4 additions & 4 deletions resin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

RESIN_HOST = os.environ.get("RESIN_HOST", "localhost")

RESIN_SCHEME = "https" if os.environ.get("RESIN_SSL", "false").lower() in ["true", "yes", "y", "1"] else "http"

ALLOWED_HOSTS = [RESIN_HOST]
RESIN_DOCKER_CONTAINER = os.environ.get("RESIN_DOCKER_CONTAINER")
if RESIN_DOCKER_CONTAINER:
Expand Down Expand Up @@ -122,10 +124,8 @@
*(["rest_framework.renderers.BrowsableAPIRenderer"] if DEBUG else []),
],
}
EDIT_PROFILE_URL = os.environ.get(
"RESIN_EDIT_PROFILE_URL", "http://localhost:3000/s-inscrire"
)
PROFILE_URL = "https://" + RESIN_HOST + "/profile"
EDIT_PROFILE_URL = RESIN_SCHEME + "://" + RESIN_HOST + "/s-inscrire"
PROFILE_URL = RESIN_SCHEME + "://" + RESIN_HOST + "/profile"

# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
Expand Down

0 comments on commit c6797b4

Please sign in to comment.