Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
05460269
Commit
05460269
authored
3 years ago
by
c-tim
Committed by
Julian
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fail if running in production and no SECRET_KEY is configured
parent
0f4561d7
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
.gitlab-ci.yml
debian/postinst
+2
-2
2 additions, 2 deletions
debian/postinst
debian/uffd.cfg
+1
-1
1 addition, 1 deletion
debian/uffd.cfg
uffd/__init__.py
+13
-9
13 additions, 9 deletions
uffd/__init__.py
with
18 additions
and
14 deletions
.gitlab-ci.yml
+
2
−
2
View file @
05460269
...
@@ -44,8 +44,8 @@ build:apt:
...
@@ -44,8 +44,8 @@ build:apt:
db_migrations_updated
:
db_migrations_updated
:
stage
:
test
stage
:
test
script
:
script
:
-
FLASK_APP=uffd flask db upgrade
-
FLASK_APP=uffd
FLASK_ENV=testing
flask db upgrade
-
FLASK_APP=uffd flask db migrate 2>&1 | grep -q 'No changes in schema detected'
-
FLASK_APP=uffd
FLASK_ENV=testing
flask db migrate 2>&1 | grep -q 'No changes in schema detected'
test_db_migrations:sqlite
:
test_db_migrations:sqlite
:
stage
:
test
stage
:
test
...
...
This diff is collapsed.
Click to expand it.
debian/postinst
+
2
−
2
View file @
05460269
...
@@ -13,8 +13,8 @@ case "$1" in
...
@@ -13,8 +13,8 @@ case "$1" in
python3
<<
EOF
python3
<<
EOF
import secrets
import secrets
cfg = open('/etc/uffd/uffd.cfg', 'r').read()
cfg = open('/etc/uffd/uffd.cfg', 'r').read()
cfg = cfg.replace('
\n
#SECRET=autogenerated by postinst script
\n
',
cfg = cfg.replace('
\n
#SECRET
_KEY
=autogenerated by postinst script
\n
',
'
\n
SECRET="'+secrets.token_hex(128)+'"
\n
', 1)
'
\n
SECRET
_KEY
="'+secrets.token_hex(128)+'"
\n
', 1)
open('/etc/uffd/uffd.cfg', 'w').write(cfg)
open('/etc/uffd/uffd.cfg', 'w').write(cfg)
EOF
EOF
chown
root:uffd /etc/uffd/uffd.cfg
chown
root:uffd /etc/uffd/uffd.cfg
...
...
This diff is collapsed.
Click to expand it.
debian/uffd.cfg
+
1
−
1
View file @
05460269
FLASK_ENV
=
"production"
FLASK_ENV
=
"production"
SQLALCHEMY_DATABASE_URI
=
"sqlite:////var/lib/uffd/db.sqlite"
SQLALCHEMY_DATABASE_URI
=
"sqlite:////var/lib/uffd/db.sqlite"
#SECRET=autogenerated by postinst script
#SECRET
_KEY
=autogenerated by postinst script
This diff is collapsed.
Click to expand it.
uffd/__init__.py
+
13
−
9
View file @
05460269
...
@@ -40,16 +40,9 @@ def load_config_file(app, cfg_name, silent=False):
...
@@ -40,16 +40,9 @@ def load_config_file(app, cfg_name, silent=False):
app
.
config
.
from_pyfile
(
cfg_path
,
silent
=
True
)
app
.
config
.
from_pyfile
(
cfg_path
,
silent
=
True
)
return
True
return
True
def
create_app
(
test_config
=
None
):
# pylint: disable=too-many-locals,too-many-statements
def
init_config
(
app
:
Flask
,
test_config
):
# create and configure the app
app
=
Flask
(
__name__
,
instance_relative_config
=
False
)
app
.
json_encoder
=
SQLAlchemyJSON
# set development default config values
# set development default config values
app
.
config
.
from_mapping
(
app
.
config
[
"
SQLALCHEMY_DATABASE_URI
"
]
=
f
"
sqlite:///
{
os
.
path
.
join
(
app
.
instance_path
,
'
uffd.sqlit3
'
)
}
"
SECRET_KEY
=
secrets
.
token_hex
(
128
),
SQLALCHEMY_DATABASE_URI
=
"
sqlite:///{}
"
.
format
(
os
.
path
.
join
(
app
.
instance_path
,
'
uffd.sqlit3
'
)),
)
app
.
config
.
from_pyfile
(
'
default_config.cfg
'
)
app
.
config
.
from_pyfile
(
'
default_config.cfg
'
)
# load config
# load config
...
@@ -64,6 +57,17 @@ def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-sta
...
@@ -64,6 +57,17 @@ def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-sta
# Prior to v1.1 login required ACL_SELFSERVICE_GROUP and ACL_ACCESS_GROUP did not exist
# Prior to v1.1 login required ACL_SELFSERVICE_GROUP and ACL_ACCESS_GROUP did not exist
app
.
config
.
setdefault
(
'
ACL_ACCESS_GROUP
'
,
app
.
config
[
'
ACL_SELFSERVICE_GROUP
'
])
app
.
config
.
setdefault
(
'
ACL_ACCESS_GROUP
'
,
app
.
config
[
'
ACL_SELFSERVICE_GROUP
'
])
if
app
.
env
==
"
production
"
and
app
.
secret_key
is
None
:
raise
Exception
(
"
SECRET_KEY not configured and we are running in production mode!
"
)
app
.
config
.
setdefault
(
"
SECRET_KEY
"
,
secrets
.
token_hex
(
128
))
def
create_app
(
test_config
=
None
):
# pylint: disable=too-many-locals,too-many-statements
# create and configure the app
app
=
Flask
(
__name__
,
instance_relative_config
=
False
)
app
.
json_encoder
=
SQLAlchemyJSON
init_config
(
app
,
test_config
)
register_template_helper
(
app
)
register_template_helper
(
app
)
setup_navbar
(
app
)
setup_navbar
(
app
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment