customize
This commit is contained in:
parent
c3727f5e4f
commit
4f9786b403
13
master.cfg
13
master.cfg
@ -5,7 +5,7 @@ import os
|
|||||||
|
|
||||||
from buildbot.plugins import *
|
from buildbot.plugins import *
|
||||||
from buildbot.www.oauth2 import OAuth2Auth
|
from buildbot.www.oauth2 import OAuth2Auth
|
||||||
from buildbot.www.authz.roles import RolesFromUsername
|
from buildbot.www.authz.roles import RolesFromBase
|
||||||
|
|
||||||
# This is a sample buildmaster config file. It must be installed as
|
# This is a sample buildmaster config file. It must be installed as
|
||||||
# 'master.cfg' in your buildmaster's base directory.
|
# 'master.cfg' in your buildmaster's base directory.
|
||||||
@ -174,10 +174,13 @@ c["titleURL"] = "https://gitea.parrrate.ru/PTV/radn-rs"
|
|||||||
c["buildbotURL"] = os.environ.get("BUILDBOT_WEB_URL", "http://localhost:8010/")
|
c["buildbotURL"] = os.environ.get("BUILDBOT_WEB_URL", "http://localhost:8010/")
|
||||||
|
|
||||||
|
|
||||||
class RolesFromCustom(RolesFromUsername):
|
class RolesFromCustom(RolesFromBase):
|
||||||
def getRolesFromUser(self, userDetails):
|
def getRolesFromUser(self, userDetails: dict):
|
||||||
print(userDetails)
|
print(userDetails)
|
||||||
return super().getRolesFromUser(userDetails)
|
if userDetails.get('is_admin') is True:
|
||||||
|
return ["admin"]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
# minimalistic config to activate new web UI
|
# minimalistic config to activate new web UI
|
||||||
@ -195,7 +198,7 @@ c["www"] = {
|
|||||||
),
|
),
|
||||||
"authz": util.Authz(
|
"authz": util.Authz(
|
||||||
allowRules=[util.AnyControlEndpointMatcher(role="admins")],
|
allowRules=[util.AnyControlEndpointMatcher(role="admins")],
|
||||||
roleMatchers=[RolesFromCustom(["admin"], ["timofey"])],
|
roleMatchers=[RolesFromCustom()],
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
if GITEA_SECRET:
|
if GITEA_SECRET:
|
||||||
|
Loading…
Reference in New Issue
Block a user