Slide 1

Slide 1 text

Oops I Commi*ed My Secret Key Philip James @phildini h*ps:/ /www.wordfugue.com

Slide 2

Slide 2 text

$ django-admin.py startproject bestthingever $ git init $ git add . $ git commit -m "Initial commit” $ git push origin master

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Wait, have I?

Slide 5

Slide 5 text

YES. Signed Cookies Secure Sessions Password Reset Tokens

Slide 6

Slide 6 text

What do I do?

Slide 7

Slide 7 text

import os import warnings from django.core.exceptions import ImproperlyConfigured def get_env_variable(var_name): """ Get the environment variable or return exception """ try: return os.environ[var_name] except KeyError: error_msg = "Set the %s env variable" % var_name if DEBUG: warnings.warn(error_msg) else: raise ImproperlyConfigured(error_msg)

Slide 8

Slide 8 text

SECRET_KEY = get_env_variable("SECRET_KEY")

Slide 9

Slide 9 text

How do I get a new key?

Slide 10

Slide 10 text

h*p:/ /www.miniwebtool.com/django-secret-key-generator/ $ python manage.py shell >>> from django.utils.crypto import get_random_string >>> get_random_string(length=50)

Slide 11

Slide 11 text

What about my users?

Slide 12

Slide 12 text

OpOonal: No permanent key

Slide 13

Slide 13 text

Thanks. @phildini h*p:/ /bit.ly/secret-key Come back at 1:15PM for “Cat on yer head”!