Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
jijisa
/
porch
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
412460b6
authored
Mar 22, 2017
by
Heechul Kim
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added etcd https support
parent
1a692008
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
10 deletions
conf/uwsgi.ini
porch/database/__init__.py
porch/settings.py.dev
scripts/create_adminpw.py
scripts/create_jwt_key.py
conf/uwsgi.ini
View file @
412460b6
[uwsgi]
[uwsgi]
workers
=
2
workers
=
2
uid
=
jijisa
master
=
true
master
=
true
socket
=
/home/%(uid)/porch/porch.sock
chdir
=
/home/%(uid)
chmod-socket
=
666
manage-script-name
=
true
manage-script-name
=
true
mount
=
/=wsgi:app
mount
=
/=wsgi:app
daemonize
=
/home/%{uid)/porch/porch.log
master
=
true
logto2
=
/home/%(uid)/porch/porch.log
procname
=
porch
log-maxsize
=
10485760
pidfile
=
/home/%{uid)/porch/porch.pid
log-backupname
=
/home/%(uid)/porch/porch.log.old
vacuum
=
true
vacuum
=
true
porch/database/__init__.py
View file @
412460b6
import
os
import
etcd
from
etcd
import
Client
from
etcd
import
Client
from
porch.settings
import
ETCD_HOST
,
ETCD_PORT
,
ETCD_PROTO
,
ETCD_PREFIX
from
porch.settings
import
ETCD_HOST
,
ETCD_PORT
,
ETCD_PROTO
,
ETCD_PREFIX
from
porch.settings
import
ETCD_CERT
,
ETCD_CA_CERT
# check if ETCD_PROTO is https but there is no ETCD_CERT and ETCD_CA_CERT.
if
ETCD_PROTO
==
'https'
:
for
f
in
ETCD_CERT
:
if
not
os
.
path
.
isfile
(
f
):
raise
Exception
(
'Fail to set ETCD: File not found {}'
.
format
(
f
))
if
not
os
.
path
.
isfile
(
ETCD_CA_CERT
):
raise
Exception
(
'Fail to set ETCD: File not found {}'
.
format
(
f
))
etcdc
=
Client
(
# Read ETCD_CA_CERT if it exists.
if
ETCD_PROTO
==
'https'
:
s_cacert
=
''
with
open
(
ETCD_CA_CERT
,
'r'
)
as
f
:
s_cacert
=
f
.
read
()
etcdc
=
Client
(
host
=
ETCD_HOST
,
port
=
ETCD_PORT
,
allow_reconnect
=
True
,
protocol
=
ETCD_PROTO
,
cert
=
ETCD_CERT
,
ca_cert
=
ETCD_CA_CERT
)
else
:
etcdc
=
Client
(
host
=
ETCD_HOST
,
host
=
ETCD_HOST
,
port
=
ETCD_PORT
,
port
=
ETCD_PORT
,
allow_reconnect
=
True
,
allow_reconnect
=
True
,
protocol
=
ETCD_PROTO
protocol
=
ETCD_PROTO
)
)
etcdc
.
prefix
=
ETCD_PREFIX
etcdc
.
prefix
=
ETCD_PREFIX
# check if ETCD_PREFIX exists on etcd server. If not, create it.
try
:
r
=
etcdc
.
read
(
etcdc
.
prefix
)
except
etcd
.
EtcdKeyNotFound
as
e
:
etcdc
.
write
(
etcdc
.
prefix
,
None
,
dir
=
True
)
porch/settings.py.dev
View file @
412460b6
# Flask settings
# Flask settings
#FLASK_SERVER_NAME = '121.254.203.198:5000'
FLASK_HOST = '0.0.0.0'
FLASK_HOST = '0.0.0.0'
FLASK_PORT = 8000
FLASK_PORT = 8000
FLASK_DEBUG = True # Do not use debug mode in production
FLASK_DEBUG = True # Do not use debug mode in production
...
@@ -13,5 +12,8 @@ RESTPLUS_ERROR_404_HELP = False
...
@@ -13,5 +12,8 @@ RESTPLUS_ERROR_404_HELP = False
# ETCD settings
# ETCD settings
ETCD_HOST = '192.168.24.31'
ETCD_HOST = '192.168.24.31'
ETCD_PORT = 2379
ETCD_PORT = 2379
ETCD_PROTO = 'http'
ETCD_PROTO = 'http'
# 'http' or 'https'
ETCD_PREFIX = '/porch'
ETCD_PREFIX = '/porch'
ETCD_CERT = ('/path/to/client_cert',
'/path/to/client_key')
ETCD_CA_CERT = '/path/to/ca_cert'
scripts/create_adminpw.py
0 → 100644
View file @
412460b6
import
bcrypt
import
getpass
p
=
getpass
.
getpass
()
salt
=
bcrypt
.
gensalt
()
pw
=
bcrypt
.
hashpw
(
bytes
(
p
,
'utf-8'
),
salt
)
print
(
"salt: {}"
.
format
(
salt
))
print
(
"adminpw: {}"
.
format
(
pw
))
scripts/create_jwt_key.py
0 → 100644
View file @
412460b6
import
os
import
binascii
print
(
binascii
.
hexlify
(
os
.
urandom
(
24
))
.
decode
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment