add config for admins

This commit is contained in:
tuxcoder 2023-12-24 11:09:41 +01:00
parent 04846aac0e
commit ddbba31fe6
4 changed files with 16 additions and 4 deletions

View file

@ -53,9 +53,12 @@
enable = true; enable = true;
domain = "example.com"; domain = "example.com";
service_domain = "account.example.com"; service_domain = "account.example.com";
settings.HYDRA_ADMIN_URL = "http://127.0.0.1:8081"; settings = {
settings.HYDRA_PUBLIC_URL = "http://127.0.0.1:8082"; HYDRA_ADMIN_URL = "http://127.0.0.1:8081";
settings.PUBLIC_URL = "http://127.0.0.1:5000"; HYDRA_PUBLIC_URL = "http://127.0.0.1:8082";
PUBLIC_URL = "http://127.0.0.1:5000";
ADMINS = [ "tuxcoder" ];
};
}; };
services.ory-hydra = { services.ory-hydra = {
enable = true; enable = true;

View file

@ -25,6 +25,9 @@ SUBJECT_PREFIX = 'something random'
OAUTH_ID = 'identiy_provider' OAUTH_ID = 'identiy_provider'
OAUTH_SECRET = 'thisIsNotSecure' OAUTH_SECRET = 'thisIsNotSecure'
ADMINS = [
'tuxcoder'
]
[LENTICULAR_CLOUD_SERVICES.jabber] [LENTICULAR_CLOUD_SERVICES.jabber]
app_token = true app_token = true

View file

@ -185,7 +185,8 @@ class User(BaseModel, ModelUpdatedMixin):
@property @property
def groups(self) -> list['Group']: def groups(self) -> list['Group']:
if self.username == 'tuxcoder': admins = current_app.config['ADMINS']
if self.username in admins:
return [Group(name='admin')] return [Group(name='admin')]
else: else:
return [] return []

View file

@ -43,6 +43,11 @@ in
description = mdDoc "public service url"; description = mdDoc "public service url";
default = "https://${cfg.service_domain}"; default = "https://${cfg.service_domain}";
}; };
ADMINS = mkOption {
type = types.listOf types.str;
description = mdDoc "list of admin users";
example = [ "tuxcoder" ];
};
DATA_FOLDER = mkOption { DATA_FOLDER = mkOption {
type = types.str; type = types.str;
default = "/var/lib/${cfg.username}"; default = "/var/lib/${cfg.username}";