Skip to content

Commit

Permalink
updated v3 warnings with varying CTA based on instance configs
Browse files Browse the repository at this point in the history
  • Loading branch information
zenmonkeykstop committed Dec 21, 2020
1 parent 2e513b1 commit 30bcae8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
14 changes: 11 additions & 3 deletions securedrop/journalist_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ def create_app(config: 'SDConfig') -> Flask:
app.config['SQLALCHEMY_DATABASE_URI'] = config.DATABASE_URI
db.init_app(app)

v2_enabled = path.exists(path.join(config.SECUREDROP_DATA_ROOT, 'source_v2_url'))
v3_enabled = path.exists(path.join(config.SECUREDROP_DATA_ROOT, 'source_v3_url'))
def _url_exists(u: str) -> bool:
return path.exists(path.join(config.SECUREDROP_DATA_ROOT, u))

v2_enabled = _url_exists('source_v2_url') or ((not _url_exists('source_v2_url'))
and (not _url_exists('source_v3_url')))
v3_enabled = _url_exists('source_v3_url')

app.config.update(V2_ONION_ENABLED=v2_enabled, V3_ONION_ENABLED=v3_enabled)

# TODO: Attaching a Storage dynamically like this disables all type checking (and
Expand Down Expand Up @@ -156,9 +161,12 @@ def setup_g() -> 'Optional[Response]':
g.html_lang = i18n.locale_to_rfc_5646(g.locale)
g.locales = i18n.get_locale2name()

if not app.config['V3_ONION_ENABLED'] or app.config['V2_ONION_ENABLED']:
if app.config['V2_ONION_ENABLED'] and not app.config['V3_ONION_ENABLED']:
g.show_v2_onion_eol_warning = True

if app.config['V2_ONION_ENABLED'] and app.config['V3_ONION_ENABLED']:
g.show_v2_onion_migration_warning = True

if request.path.split('/')[1] == 'api':
pass # We use the @token_required decorator for the API endpoints
else: # We are not using the API
Expand Down
10 changes: 8 additions & 2 deletions securedrop/journalist_templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@

{% if g.user %}
{% if g.show_v2_onion_eol_warning %}
<div id="v2-onion-eol" class="warning-banner">
{{ gettext('<strong>Update Required:</strong> Your SecureDrop servers are still running v2 onion services, which are being phased out for security reasons. In February 2021, v2 onion services will be disabled, and your SecureDrop servers may become unreachable. <a href="//securedrop.org/v2-onion-eol" rel="noreferrer">Learn More</a>') }}
<div id="v2-onion-eol" class="alert-banner">
{{ gettext('<strong>Update Required:</strong> You must switch your SecureDrop to v3 onion services to ensure that it is reachable after April 30, 2021. <a href="//securedrop.org/v2-onion-eol" rel="noreferrer">Learn More</a>') }}
</div>
{% endif %}

{% if g.show_v2_onion_migration_warning %}
<div id="v2-onion-eol" class="alert-banner">
{{ gettext('<strong>Update Required:</strong> Your SecureDrop servers are still reachable via v2 and v3 onion services. Make sure admins, journalists, and sources are using v3 onion services - then disable v2 onion services. <a href="//securedrop.org/v2-onion-eol" rel="noreferrer">Learn More</a>') }}
</div>
{% endif %}

Expand Down
3 changes: 3 additions & 0 deletions securedrop/sass/_base.sass
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
@import modules/warning
// Warning - Warning messages that show up in a banner to the user.
@import modules/warning-banner
// Alert - Urgent messages requiring action that show up in a banner to the user.
@import modules/alert-banner
// Confirm prompt - When deleting something this prompt is shown
@import modules/confirm-prompt
// 'Serious' text - Seems to be unused. Delete?
Expand Down Expand Up @@ -122,6 +124,7 @@
+panel
+warning
+warning-banner
+alert-banner
+confirm-prompt
+serious-text
+code
Expand Down
17 changes: 17 additions & 0 deletions securedrop/sass/modules/_alert-banner.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=alert-banner
.alert-banner
display: block
background-color: $color_warning_red
color: white
padding: 10px 0
width: 100%
text-align: center
font-size: small
box-sizing: border-box
-moz-box-sizing: border-box

a
color: white

.close
cursor: pointer

0 comments on commit 30bcae8

Please sign in to comment.