chg: properly create a secret key

pull/12/head
Raphaël Vinot 2019-01-17 16:33:31 +01:00
parent 5e4264a411
commit 2f7c286312
3 changed files with 23 additions and 5 deletions

3
.gitignore vendored
View File

@ -122,4 +122,7 @@ website/web/static/d3*.js
# Same got bootstrap-select
website/web/static/bootstrap-select*
# Session key
website/secret_key
*.swp

View File

@ -12,7 +12,7 @@ New version of BGP Ranking, complete rewrite in python3.6+ and an ARDB backend
```bash
git clone https://github.com/antirez/redis.git
cd redis
git checkout 4.0
git checkout 5.0
make
make test
cd ..
@ -23,11 +23,11 @@ cd ..
```bash
git clone https://github.com/yinqiwen/ardb.git
cd ardb
make
DISABLE_WARNING_AS_ERROR=1 make # ardb (more precisely rocksdb) doesn't compile on ubuntu 18.04 unless you disable warning as error
cd ..
```
## Install BGP Ranking
## Install & run BGP Ranking
```bash
git clone https://github.com/D4-project/BGP-Ranking.git
@ -41,6 +41,12 @@ start.py
start_website.py
```
## Shutdown BGP Ranking
```bash
stop.py
```
# Directory structure
*Config files*: `bgpranking / config / *.json`

View File

@ -7,6 +7,8 @@ try:
except ImportError:
import json
import os
import requests
from flask import Flask, render_template, request, session, Response, redirect, url_for
@ -14,14 +16,21 @@ from flask_bootstrap import Bootstrap
from bgpranking.querying import Querying
from bgpranking.libs.exceptions import MissingConfigEntry
from bgpranking.libs.helpers import load_general_config
from bgpranking.libs.helpers import load_general_config, get_homedir
from datetime import date, timedelta
import pycountry
from collections import defaultdict
app = Flask(__name__)
app.secret_key = '\xeb\xfd\x1b\xee\xed<\xa5~\xd5H\x85\x00\xa5r\xae\x80t5@\xa2&>\x03S'
secret_file_path = get_homedir() / 'website' / 'secret_key'
if not secret_file_path.exists() or secret_file_path.stat().st_size < 64:
with open(secret_file_path, 'wb') as f:
f.write(os.urandom(64))
with open(secret_file_path, 'rb') as f:
app.config['SECRET_KEY'] = f.read()
Bootstrap(app)
app.config['BOOTSTRAP_SERVE_LOCAL'] = True