Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow staying logged in for longer #4236

Merged
merged 5 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
7 changes: 6 additions & 1 deletion readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ class CommunityBaseSettings(Settings):
DEFAULT_FROM_EMAIL = '[email protected]'
SERVER_EMAIL = DEFAULT_FROM_EMAIL

# Cookies
# Sessions
SESSION_COOKIE_DOMAIN = 'readthedocs.org'
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_AGE = 30 * 24 * 60 * 60 # 30 days
SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
Copy link
Member

Choose a reason for hiding this comment

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

If we are going to use signed cookies, don't we want to remove django.contrib.sessions from INSTALLED_APPS?. What I understand from the documentation it's only used for database-cookies.

https://docs.djangoproject.com/en/1.11/topics/http/sessions/#using-database-backed-sessions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking of actually taking this change out and making this a setting that is set in the production settings rather than in the base settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are advantages to signed cookies but they aren't huge and they are what's holding this up due to the complications with the corporate site.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the SESSION_ENGINE setting here. If we decide to change the production SESSION_ENGINE, we'll do that in the production settings file. This will ensure that anyone taking our code and using it don't have a SESSION_ENGINE change unless they want one.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. 👍

SESSION_SAVE_EVERY_REQUEST = True

# CSRF
CSRF_COOKIE_HTTPONLY = True
CSRF_COOKIE_AGE = 30 * 24 * 60 * 60

Expand Down
51 changes: 26 additions & 25 deletions readthedocs/templates/profiles/private/advertising_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,44 @@
{% block edit_content_header %} {% trans "Set advertising preferences" %} {% endblock %}

{% block edit_content %}
<p>
{% blocktrans %}
Read the Docs is an open source project.
In order to maintain service, we rely on both the
support of our users, and from sponsor support.
{% endblocktrans %}
</p>

<p>
{% blocktrans %}
For more details on advertising on Read the Docs
including the privacy protections we have in place for users
and community advertising we run on behalf of the open source community,
see <a href="https://docs.readthedocs.io/en/latest/ethical-advertising.html">our documentation</a>.
{% endblocktrans %}
</p>

{% if request.user.gold.exists or request.user.goldonce.exists %}
<p>
{% blocktrans %}
<strong>Note:</strong>
Since you are a Gold Member or donor, you <strong>will not</strong> see advertising as long as you are logged-in.
Since you are a Gold Member or Supporter, you are <strong>ad-free</strong> for as long as you are logged-in.
Thank you for supporting Read the Docs.
{% endblocktrans%}
</p>
{% else %}
<p>
{% blocktrans %}
Read the Docs is an open source project.
In order to maintain service, we rely on both the
support of our users, and from sponsor support.
{% endblocktrans %}
</p>

<p>
{% blocktrans %}
For more details on advertising on Read the Docs
including the privacy protections we have in place for users
and community advertising we run on behalf of the open source community,
see <a href="https://docs.readthedocs.io/en/latest/ethical-advertising.html">our documentation</a>.
{% endblocktrans %}
</p>

<p>
{% url "gold_detail" as gold_detail %}
{% url "donate" as donate_url %}
{% blocktrans %}
You may remove ads completely by becoming a <a href="{{ gold_detail }}">Gold member to Read the Docs</a>.
You can <strong>go ad-free</strong> by becoming a <a href="{{ gold_detail }}">Gold Member</a> or <a href="{{ donate_url }}">Supporter</a> of Read the Docs</a>.
{% endblocktrans %}
</p>
{% endif %}

<form method="POST" action=".">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="{% trans "Update advertisement preference" %}" id="submit"/>
</form>
<form method="POST" action=".">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="{% trans "Update advertisement preference" %}" id="submit"/>
</form>
{% endif %}
{% endblock %}