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
b2c997ef
Commit
b2c997ef
authored
3 years ago
by
sistason
Browse files
Options
Downloads
Patches
Plain Diff
Allow Config as json or yaml
parent
193a2eff
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+7
-1
7 additions, 1 deletion
README.md
uffd/__init__.py
+28
-7
28 additions, 7 deletions
uffd/__init__.py
with
35 additions
and
8 deletions
README.md
+
7
−
1
View file @
b2c997ef
...
@@ -61,6 +61,13 @@ hook-pre-app = exec:FLASK_APP=uffd flask db upgrade
...
@@ -61,6 +61,13 @@ hook-pre-app = exec:FLASK_APP=uffd flask db upgrade
tabs.
tabs.
## Config
Uffd reads its default config from
`uffd/default_config.cfg`
.
You can overwrite config variables by creating a config file in the
`instance`
folder.
The file must be named
`conifg.cfg`
(Python syntax),
`config.json`
or
`config.yml`
/
`config.yaml`
.
You can also set a custom file name with the environment variable
`CONFIG_FILENAME`
.
## Bind with service account or as user?
## Bind with service account or as user?
Uffd can use a dedicated service account for LDAP operations by setting
`LDAP_SERVICE_BIND_DN`
.
Uffd can use a dedicated service account for LDAP operations by setting
`LDAP_SERVICE_BIND_DN`
.
...
@@ -70,7 +77,6 @@ Or set `LDAP_SERVICE_USER_BIND` to use the credentials of the currently logged i
...
@@ -70,7 +77,6 @@ Or set `LDAP_SERVICE_USER_BIND` to use the credentials of the currently logged i
If you choose to run with user credentials, some features are not available, like password resets
If you choose to run with user credentials, some features are not available, like password resets
or self signup, since in both cases, no user credentials can exist.
or self signup, since in both cases, no user credentials can exist.
## OAuth2 Single-Sign-On Provider
## OAuth2 Single-Sign-On Provider
Other services can use uffd as an OAuth2.0-based authentication provider.
Other services can use uffd as an OAuth2.0-based authentication provider.
...
...
This diff is collapsed.
Click to expand it.
uffd/__init__.py
+
28
−
7
View file @
b2c997ef
...
@@ -18,6 +18,24 @@ from uffd.template_helper import register_template_helper
...
@@ -18,6 +18,24 @@ from uffd.template_helper import register_template_helper
from
uffd.navbar
import
setup_navbar
from
uffd.navbar
import
setup_navbar
# pylint: enable=wrong-import-position
# pylint: enable=wrong-import-position
def
load_config_file
(
app
,
cfg_name
,
silent
=
False
):
cfg_path
=
os
.
path
.
join
(
app
.
instance_path
,
cfg_name
)
if
not
os
.
path
.
exists
(
cfg_path
):
if
not
silent
:
raise
Exception
(
f
"
Config file
{
cfg_path
}
not found
"
)
return
False
if
cfg_path
.
endswith
(
"
.json
"
):
app
.
config
.
from_json
(
cfg_path
)
elif
cfg_path
.
endswith
(
"
.yaml
"
)
or
cfg_path
.
endswith
(
"
.yml
"
):
import
yaml
# pylint: disable=import-outside-toplevel disable=import-error
with
open
(
cfg_path
,
encoding
=
'
utf-8
'
)
as
ymlfile
:
data
=
yaml
.
safe_load
(
ymlfile
)
app
.
config
.
from_mapping
(
data
)
else
:
app
.
config
.
from_pyfile
(
cfg_path
,
silent
=
True
)
return
True
def
create_app
(
test_config
=
None
):
# pylint: disable=too-many-locals
def
create_app
(
test_config
=
None
):
# pylint: disable=too-many-locals
# create and configure the app
# create and configure the app
app
=
Flask
(
__name__
,
instance_relative_config
=
False
)
app
=
Flask
(
__name__
,
instance_relative_config
=
False
)
...
@@ -30,16 +48,19 @@ def create_app(test_config=None): # pylint: disable=too-many-locals
...
@@ -30,16 +48,19 @@ def create_app(test_config=None): # pylint: disable=too-many-locals
)
)
app
.
config
.
from_pyfile
(
'
default_config.cfg
'
)
app
.
config
.
from_pyfile
(
'
default_config.cfg
'
)
# load config
if
test_config
is
not
None
:
app
.
config
.
from_mapping
(
test_config
)
elif
os
.
environ
.
get
(
"
CONFIG_FILENAME
"
):
load_config_file
(
app
,
os
.
environ
[
"
CONFIG_FILENAME
"
],
silent
=
False
)
else
:
for
cfg_name
in
[
"
config.cfg
"
,
"
config.json
"
,
"
config.yml
"
,
"
config.yaml
"
]:
if
load_config_file
(
app
,
cfg_name
,
silent
=
True
):
break
register_template_helper
(
app
)
register_template_helper
(
app
)
setup_navbar
(
app
)
setup_navbar
(
app
)
if
not
test_config
:
# load the instance config, if it exists, when not testing
app
.
config
.
from_pyfile
(
os
.
path
.
join
(
app
.
instance_path
,
'
config.cfg
'
),
silent
=
True
)
else
:
# load the test config if passed in
app
.
config
.
from_mapping
(
test_config
)
# ensure the instance folder exists
# ensure the instance folder exists
try
:
try
:
os
.
makedirs
(
app
.
instance_path
)
os
.
makedirs
(
app
.
instance_path
)
...
...
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