mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-03 10:48:03 +08:00
Allow optional authz, to make dev much simpler.
This commit is contained in:
@@ -40,6 +40,7 @@ class BaseConfiguration(object):
|
||||
PKGDB_API_URL = 'https://admin.stg.fedoraproject.org/pkgdb/api'
|
||||
|
||||
FAS_URL = 'https://admin.stg.fedoraproject.org/accounts'
|
||||
REQUIRE_PACKAGER = True
|
||||
|
||||
# Available backends are: console, file, journal.
|
||||
LOG_BACKEND = 'journal'
|
||||
@@ -69,7 +70,10 @@ class DevConfiguration(BaseConfiguration):
|
||||
LOG_BACKEND = 'console'
|
||||
LOG_LEVEL = 'debug'
|
||||
HOST = '0.0.0.0'
|
||||
FAS_USERNAME = 'put your fas username here'
|
||||
REQUIRE_PACKAGER = False
|
||||
# You only need these FAS options if you turn on authorization
|
||||
# with REQUIRE_PACKAGER=True
|
||||
#FAS_USERNAME = 'put your fas username here'
|
||||
#FAS_PASSWORD = 'put your fas password here....'
|
||||
#FAS_PASSWORD = os.environ('FAS_PASSWORD') # you could store it here
|
||||
#FAS_PASSWORD = commands.getoutput('pass your_fas_password').strip()
|
||||
|
||||
@@ -72,6 +72,7 @@ class Config(object):
|
||||
self._fas_url = ""
|
||||
self._fas_username = ""
|
||||
self._fas_password = ""
|
||||
self._require_packager = True
|
||||
self._log_backend = ""
|
||||
self._log_file = ""
|
||||
self._log_level = 0
|
||||
@@ -344,6 +345,14 @@ class Config(object):
|
||||
def fas_password(self, s):
|
||||
self._fas_password = str(s)
|
||||
|
||||
@property
|
||||
def require_packager(self):
|
||||
return self._require_packager
|
||||
|
||||
@require_packager.setter
|
||||
def require_packager(self, s):
|
||||
self._require_packager = bool(s)
|
||||
|
||||
@property
|
||||
def log_backend(self):
|
||||
return self._log_backend
|
||||
|
||||
@@ -76,10 +76,12 @@ class ModuleBuildAPI(MethodView):
|
||||
|
||||
def post(self):
|
||||
username = module_build_service.auth.get_username(request.environ)
|
||||
module_build_service.auth.assert_is_packager(username, fas_kwargs=dict(
|
||||
base_url=conf.fas_url,
|
||||
username=conf.fas_username,
|
||||
password=conf.fas_password))
|
||||
|
||||
if conf.require_packager:
|
||||
module_build_service.auth.assert_is_packager(username, fas_kwargs=dict(
|
||||
base_url=conf.fas_url,
|
||||
username=conf.fas_username,
|
||||
password=conf.fas_password))
|
||||
|
||||
try:
|
||||
r = json.loads(request.get_data().decode("utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user