Permalink
Browse files

merged master in

  • Loading branch information...
2 parents dc85853 + 101410f commit c3b967fb14cf443f69c5a650c59133b41ad7317e @hellerbarde committed Apr 5, 2012
Showing with 4 additions and 5 deletions.
  1. +2 −2 create_config.py
  2. +2 −3 simple.py
View
@@ -1,4 +1,4 @@
-import hashlib
+from werkzeug.security import generate_password_hash
def input_with_default(prompt, default):
x = raw_input("%s (Default %s) "%(prompt, default))
@@ -10,7 +10,7 @@ def input_with_default(prompt, default):
print "Generating a Simple config file. Please answer some questions:"
fd.write("POSTS_PER_PAGE = %s\n"%input_with_default("Posts per page", 5))
fd.write("ADMIN_USERNAME = '%s'\n"%input_with_default("Admin username","admin"))
- fd.write("ADMIN_PASSWORD = '%s'\n"%hashlib.md5(input_with_default("Admin password","password")).hexdigest())
+ fd.write("ADMIN_PASSWORD = '%s'\n"%generate_password_hash(input_with_default("Admin password","password")) )
fd.write("MARKDOWN_EXTS = [%s]\n"%",".join(map(lambda x: '"'+x+'"', input_with_default("Markdown Extensions (Separated by spaces)", "").split())))
fd.write("ANALYTICS_ID = '%s'\n"%input_with_default("Google analytics ID",""))
fd.write('SQLALCHEMY_DATABASE_URI = "%s"\n'%input_with_default("Database URI","sqlite:///simple.db"))
View
@@ -1,12 +1,11 @@
from functools import wraps
-import hashlib
from flask import render_template, request, Flask, flash, redirect, url_for, abort, jsonify, Response, make_response
import re
from unicodedata import normalize
from flaskext.sqlalchemy import SQLAlchemy
import datetime
-from unicodedata import normalize
import markdown
+from werkzeug.security import check_password_hash
app = Flask(__name__)
app.config.from_object('settings')
@@ -38,7 +37,7 @@ def requires_authentication(f):
def _auth_decorator(*args, **kwargs):
auth = request.authorization
if not auth or not (auth.username == app.config["ADMIN_USERNAME"]
- and hashlib.md5(auth.password).hexdigest() == app.config["ADMIN_PASSWORD"]):
+ and check_password_hash(app.config["ADMIN_PASSWORD"], auth.password)):
return Response("Could not authenticate you", 401, {"WWW-Authenticate":'Basic realm="Login Required"'})
return f(*args, **kwargs)

0 comments on commit c3b967f

Please sign in to comment.