All of lore.kernel.org
 help / color / mirror / Atom feed
* [layerindex-web][PATCH] views: add ability to force https URL in layer review emails
@ 2017-07-21  9:40 Paul Eggleton
  0 siblings, 0 replies; only message in thread
From: Paul Eggleton @ 2017-07-21  9:40 UTC (permalink / raw)
  To: yocto

At the moment the URL that is presented in the review email will have
http:// or https:// prefix depending on what the user who submitted the
layer was using, but that's irrelevant - we actually want https:// if
the server is capable of it since the reviewer may be redirected to log
in (and Django's login_required decorator will always redirect to the
login page if http is being used as far as I observed, which is a bit
annoying if you are already logged in.) Add a setting which if enabled
will substitute https:// as the prefix.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 layerindex/views.py | 5 ++++-
 settings.py         | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/layerindex/views.py b/layerindex/views.py
index 2f7d45e..eaeb5c3 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -169,10 +169,13 @@ def edit_layer_view(request, template_name, branch='master', slug=None):
                             user_name = user.first_name
                         else:
                             user_name = user.username
+                        layer_url = request.build_absolute_uri(reverse('layer_review', args=(layeritem.name,)))
+                        if getattr(settings, 'FORCE_REVIEW_HTTPS', False) and layer_url.startswith('http:'):
+                            layer_url = 'https:' + layer_url.split(':', 1)[1]
                         d = Context({
                             'user_name': user_name,
                             'layer_name': layeritem.name,
-                            'layer_url': request.build_absolute_uri(reverse('layer_review', args=(layeritem.name,))),
+                            'layer_url': layer_url,
                         })
                         subject = '%s - %s' % (settings.SUBMIT_EMAIL_SUBJECT, layeritem.name)
                         from_email = settings.SUBMIT_EMAIL_FROM
diff --git a/settings.py b/settings.py
index 3318af1..92146f8 100644
--- a/settings.py
+++ b/settings.py
@@ -217,6 +217,10 @@ UPDATE_PURGE_DAYS = 30
 # Remove layer dependencies that are not specified in conf/layer.conf
 REMOVE_LAYER_DEPENDENCIES = False
 
+# Always use https:// for review URLs in emails (since it may be redirected to
+# the login page)
+FORCE_REVIEW_HTTPS = False
+
 # Settings for layer submission feature
 SUBMIT_EMAIL_FROM = 'noreply@example.com'
 SUBMIT_EMAIL_SUBJECT = 'OE Layerindex layer submission'
-- 
2.9.4



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-21  9:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-21  9:40 [layerindex-web][PATCH] views: add ability to force https URL in layer review emails Paul Eggleton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.