Update comentario
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -26,7 +26,7 @@ in
|
|||||||
POSTGRES_PASSWORD=${hmConfig.sops.placeholder."comentario/postgresql"}
|
POSTGRES_PASSWORD=${hmConfig.sops.placeholder."comentario/postgresql"}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
comentario.content = builtins.readFile (
|
comentario-secrets.content = builtins.readFile (
|
||||||
(pkgs.formats.yaml { }).generate "secrets.yaml" {
|
(pkgs.formats.yaml { }).generate "secrets.yaml" {
|
||||||
postgres = {
|
postgres = {
|
||||||
host = "comentario-postgresql";
|
host = "comentario-postgresql";
|
||||||
@@ -56,6 +56,7 @@ in
|
|||||||
];
|
];
|
||||||
key = autheliaClientId;
|
key = autheliaClientId;
|
||||||
secret = hmConfig.sops.placeholder."comentario/authelia/password";
|
secret = hmConfig.sops.placeholder."comentario/authelia/password";
|
||||||
|
superuserClaim = "is_admin";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -110,16 +111,27 @@ in
|
|||||||
networks.comentario.ref
|
networks.comentario.ref
|
||||||
networks.traefik.ref
|
networks.traefik.ref
|
||||||
];
|
];
|
||||||
environments = {
|
volumes =
|
||||||
BASE_URL = "https://comments.karaolidis.com";
|
let
|
||||||
NO_COLOR = "true";
|
config = (pkgs.formats.yaml { }).generate "config.yaml" {
|
||||||
SUPERUSER_CLAIM = "is_admin";
|
baseUrl = "https://comments.karaolidis.com";
|
||||||
DYN_DEFAULT_AUTH_EMAILUPDATE_ENABLED = "true";
|
log.noColor = true;
|
||||||
DYN_DEFAULT_AUTH_SIGNUP_CONFIRM_COMMENTER = "false";
|
|
||||||
DYN_DEFAULT_AUTH_SIGNUP_ENABLED = "false";
|
dynamicConfigDefaults.auth = {
|
||||||
DYN_DEFAULT_AUTH_SIGNUP_SSO_ENABLED = "true";
|
emailUpdate.enabled = true;
|
||||||
};
|
|
||||||
volumes = [ "${hmConfig.sops.templates.comentario.path}:/etc/comentario/secrets.yaml:ro" ];
|
signup = {
|
||||||
|
confirm.commenter = false;
|
||||||
|
enabled = false;
|
||||||
|
sso.enabled = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
[
|
||||||
|
"${config}:/etc/comentario/config.yaml:ro"
|
||||||
|
"${hmConfig.sops.templates.comentario-secrets.path}:/etc/comentario/secrets.yaml:ro"
|
||||||
|
];
|
||||||
labels = [
|
labels = [
|
||||||
"traefik.enable=true"
|
"traefik.enable=true"
|
||||||
"traefik.http.routers.comentario.rule=Host(`comments.karaolidis.com`)"
|
"traefik.http.routers.comentario.rule=Host(`comments.karaolidis.com`)"
|
||||||
|
@@ -2,24 +2,17 @@
|
|||||||
# AUTO-UPDATE: nix-update --flake comentario --version=branch=dev --subpackage frontend
|
# AUTO-UPDATE: nix-update --flake comentario --version=branch=dev --subpackage frontend
|
||||||
pkgs.buildGo125Module (finalAttrs: {
|
pkgs.buildGo125Module (finalAttrs: {
|
||||||
pname = "comentario";
|
pname = "comentario";
|
||||||
version = "3.14.0-unstable-2025-09-15";
|
version = "3.14.0-unstable-2025-09-20";
|
||||||
|
|
||||||
src = pkgs.fetchFromGitLab {
|
src = pkgs.fetchFromGitLab {
|
||||||
owner = "comentario";
|
owner = "comentario";
|
||||||
repo = "comentario";
|
repo = "comentario";
|
||||||
# FIXME: Stable rev once type error is fixed
|
# FIXME: Stable rev once type error is fixed
|
||||||
rev = "d79035b41a912a432b74eb7fb0240b79cabff6bf";
|
rev = "73cf8040cb9adb31794ec780e5905c2e747ca63f";
|
||||||
hash = "sha256-nTOojxYBDeA5Z+rh+C+SbFJ4fzmr8sT2oZmO+chiXJM=";
|
hash = "sha256-8rch1sL81wQblaUBebUA/C2HxtAfYHPadt2X2qJWJIk=";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
patches = [ ./superuser-claim.patch ];
|
||||||
# fe: dynamic configuration env vars
|
|
||||||
(builtins.fetchurl {
|
|
||||||
url = "https://gitlab.com/comentario/comentario/-/merge_requests/23.patch";
|
|
||||||
sha256 = "sha256:0ih5hwadjkh47vvji4jygpfxcfpjcarhcwazc7asxpfxc87g04pv";
|
|
||||||
})
|
|
||||||
./superuser-claim.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
vendorHash = "sha256-AOI/WnVkrSgJlT2FtYOTuifOPw8sfc4C0g/prVkvJlA=";
|
vendorHash = "sha256-AOI/WnVkrSgJlT2FtYOTuifOPw8sfc4C0g/prVkvJlA=";
|
||||||
|
|
||||||
@@ -72,13 +65,10 @@ pkgs.buildGo125Module (finalAttrs: {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin $out/lib/${finalAttrs.pname}
|
mkdir -p $out/bin
|
||||||
cp -r $GOPATH/bin/comentario $out/bin/${finalAttrs.pname}
|
cp -r $GOPATH/bin/comentario $out/bin/${finalAttrs.pname}
|
||||||
cp -r db templates $out/lib/${finalAttrs.pname}
|
|
||||||
|
|
||||||
wrapProgram $out/bin/${finalAttrs.pname} \
|
wrapProgram $out/bin/${finalAttrs.pname} \
|
||||||
--add-flags "--db-migration-path=$out/lib/${finalAttrs.pname}/db" \
|
|
||||||
--add-flags "--template-path=$out/lib/${finalAttrs.pname}/templates" \
|
|
||||||
--add-flags "--static-path=${finalAttrs.frontend}"
|
--add-flags "--static-path=${finalAttrs.frontend}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ index 7d3dc792..723e8149 100644
|
|||||||
[InstanceConfigItemKey.operationNewOwnerEnabled]: $localize`Non-owner users can add domains`,
|
[InstanceConfigItemKey.operationNewOwnerEnabled]: $localize`Non-owner users can add domains`,
|
||||||
// Domain defaults
|
// Domain defaults
|
||||||
diff --git a/internal/api/restapi/handlers/oauth.go b/internal/api/restapi/handlers/oauth.go
|
diff --git a/internal/api/restapi/handlers/oauth.go b/internal/api/restapi/handlers/oauth.go
|
||||||
index 0d8cd282..01324302 100644
|
index 8c5129f2..3837d229 100644
|
||||||
--- a/internal/api/restapi/handlers/oauth.go
|
--- a/internal/api/restapi/handlers/oauth.go
|
||||||
+++ b/internal/api/restapi/handlers/oauth.go
|
+++ b/internal/api/restapi/handlers/oauth.go
|
||||||
@@ -220,7 +220,7 @@ func AuthOauthCallback(params api_general.AuthOauthCallbackParams) middleware.Re
|
@@ -220,7 +220,7 @@ func AuthOauthCallback(params api_general.AuthOauthCallbackParams) middleware.Re
|
||||||
@@ -156,15 +156,26 @@ index 0d8cd282..01324302 100644
|
|||||||
|
|
||||||
} else if sso {
|
} else if sso {
|
||||||
// SSO embed signup
|
// SSO embed signup
|
||||||
@@ -248,9 +248,18 @@ func AuthOauthCallback(params api_general.AuthOauthCallbackParams) middleware.Re
|
@@ -248,9 +248,29 @@ func AuthOauthCallback(params api_general.AuthOauthCallbackParams) middleware.Re
|
||||||
return errors.New(errMessage)
|
return errors.New(errMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Check if the superuser claim is set
|
+ // Check if the superuser claim is set
|
||||||
+ superuser := false
|
+ superuser := false
|
||||||
+ if raw, ok := fedUser.RawData[config.ServerConfig.SuperuserClaim]; ok {
|
+ if fidp, ok := config.FederatedIdProviders[models.FederatedIdpID(idpID)]; ok {
|
||||||
+ if isAdmin, ok := raw.(bool); ok && isAdmin {
|
+ if fidp.SuperuserClaim != "" {
|
||||||
+ superuser = true
|
+ if raw, ok := fedUser.RawData[fidp.SuperuserClaim]; ok {
|
||||||
|
+ switch v := raw.(type) {
|
||||||
|
+ case bool:
|
||||||
|
+ if v {
|
||||||
|
+ superuser = true
|
||||||
|
+ }
|
||||||
|
+ case string:
|
||||||
|
+ if v == "true" || v == "1" {
|
||||||
|
+ superuser = true
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@@ -173,25 +184,51 @@ index 0d8cd282..01324302 100644
|
|||||||
WithConfirmed(true). // Confirm the user right away as we trust the IdP
|
WithConfirmed(true). // Confirm the user right away as we trust the IdP
|
||||||
+ WithSuperuser(superuser).
|
+ WithSuperuser(superuser).
|
||||||
WithLangFromReq(params.HTTPRequest).
|
WithLangFromReq(params.HTTPRequest).
|
||||||
WithSignup(params.HTTPRequest, authSession.Host, !config.ServerConfig.LogFullIPs).
|
WithSignup(params.HTTPRequest, authSession.Host, !config.ServerConfig.Logging.FullIPs).
|
||||||
WithFederated(fedUser.UserID, idpID).
|
WithFederated(fedUser.UserID, idpID).
|
||||||
diff --git a/internal/config/config.go b/internal/config/config.go
|
diff --git a/internal/config/oauth.go b/internal/config/oauth.go
|
||||||
index e1292447..1715a7f6 100644
|
index 10917c44..7ba997d9 100644
|
||||||
--- a/internal/config/config.go
|
--- a/internal/config/oauth.go
|
||||||
+++ b/internal/config/config.go
|
+++ b/internal/config/oauth.go
|
||||||
@@ -36,6 +36,7 @@ type ServerConfiguration struct {
|
@@ -177,9 +177,10 @@ func oidcConfigure() error {
|
||||||
TemplatePath string `long:"template-path" description:"Path to template files" default:"./templates" env:"TEMPLATE_PATH"`
|
// Add it to the configured providers map
|
||||||
SecretsFile string `long:"secrets" description:"Path to YAML file with secrets" default:"secrets.yaml" env:"SECRETS_FILE"`
|
mid := models.FederatedIdpID(qid)
|
||||||
Superuser string `long:"superuser" description:"ID or email of user to be made superuser" default:"" env:"SUPERUSER"`
|
FederatedIdProviders[mid] = &data.FederatedIdentityProvider{
|
||||||
+ SuperuserClaim string `long:"superuser-claim" description:"Name of the OIDC claim for superusers" default:"is_superuser" env:"SUPERUSER_CLAIM"`
|
- ID: mid,
|
||||||
LogFullIPs bool `long:"log-full-ips" description:"Log IP addresses in full" env:"LOG_FULL_IPS"`
|
- Name: p.Name,
|
||||||
HomeContentURL string `long:"home-content-url" description:"URL of a HTML page to display on homepage" env:"HOME_CONTENT_URL"`
|
- GothName: qid,
|
||||||
GitLabURL string `long:"gitlab-url" description:"Custom GitLab URL for authentication" default:"" env:"GITLAB_URL"`
|
+ ID: mid,
|
||||||
|
+ Name: p.Name,
|
||||||
|
+ GothName: qid,
|
||||||
|
+ SuperuserClaim: p.SuperuserClaim,
|
||||||
|
}
|
||||||
|
cnt++
|
||||||
|
}
|
||||||
|
diff --git a/internal/config/secrets.go b/internal/config/secrets.go
|
||||||
|
index d3e2af97..92f33f74 100644
|
||||||
|
--- a/internal/config/secrets.go
|
||||||
|
+++ b/internal/config/secrets.go
|
||||||
|
@@ -59,10 +59,11 @@ type APIKey struct {
|
||||||
|
|
||||||
|
// OIDCProvider stores OIDC provider configuration
|
||||||
|
type OIDCProvider struct {
|
||||||
|
- KeySecretURL `yaml:",inline"`
|
||||||
|
- ID string `yaml:"id"` // Unique provider ID, e.g. "keycloak"
|
||||||
|
- Name string `yaml:"name"` // Provider display name, e.g. "Keycloak"
|
||||||
|
- Scopes []string `yaml:"scopes"` // Additional scopes to request
|
||||||
|
+ KeySecretURL `yaml:",inline"`
|
||||||
|
+ ID string `yaml:"id"` // Unique provider ID, e.g. "keycloak"
|
||||||
|
+ Name string `yaml:"name"` // Provider display name, e.g. "Keycloak"
|
||||||
|
+ Scopes []string `yaml:"scopes"` // Additional scopes to request
|
||||||
|
+ SuperuserClaim string `yaml:"superuserClaim"` // Name of the OIDC claim for superusers
|
||||||
|
}
|
||||||
|
|
||||||
|
// QualifiedID returns the provider's ID prepended with the common OIDC prefix
|
||||||
diff --git a/internal/data/dyn_config.go b/internal/data/dyn_config.go
|
diff --git a/internal/data/dyn_config.go b/internal/data/dyn_config.go
|
||||||
index 8595ea2a..621fd132 100644
|
index 0cd0d64e..b4ff042d 100644
|
||||||
--- a/internal/data/dyn_config.go
|
--- a/internal/data/dyn_config.go
|
||||||
+++ b/internal/data/dyn_config.go
|
+++ b/internal/data/dyn_config.go
|
||||||
@@ -170,6 +170,7 @@ const (
|
@@ -171,6 +171,7 @@ const (
|
||||||
ConfigKeyAuthSignupConfirmCommenter DynConfigItemKey = "auth.signup.confirm.commenter"
|
ConfigKeyAuthSignupConfirmCommenter DynConfigItemKey = "auth.signup.confirm.commenter"
|
||||||
ConfigKeyAuthSignupConfirmUser DynConfigItemKey = "auth.signup.confirm.user"
|
ConfigKeyAuthSignupConfirmUser DynConfigItemKey = "auth.signup.confirm.user"
|
||||||
ConfigKeyAuthSignupEnabled DynConfigItemKey = "auth.signup.enabled"
|
ConfigKeyAuthSignupEnabled DynConfigItemKey = "auth.signup.enabled"
|
||||||
@@ -199,7 +236,7 @@ index 8595ea2a..621fd132 100644
|
|||||||
ConfigKeyIntegrationsUseGravatar DynConfigItemKey = "integrations.useGravatar"
|
ConfigKeyIntegrationsUseGravatar DynConfigItemKey = "integrations.useGravatar"
|
||||||
ConfigKeyOperationNewOwnerEnabled DynConfigItemKey = "operation.newOwner.enabled"
|
ConfigKeyOperationNewOwnerEnabled DynConfigItemKey = "operation.newOwner.enabled"
|
||||||
)
|
)
|
||||||
@@ -203,6 +204,7 @@ var DefaultDynInstanceConfig = DynConfigMap{
|
@@ -204,6 +205,7 @@ var DefaultDynInstanceConfig = DynConfigMap{
|
||||||
ConfigKeyAuthSignupConfirmCommenter: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionAuth},
|
ConfigKeyAuthSignupConfirmCommenter: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionAuth},
|
||||||
ConfigKeyAuthSignupConfirmUser: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionAuth},
|
ConfigKeyAuthSignupConfirmUser: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionAuth},
|
||||||
ConfigKeyAuthSignupEnabled: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionAuth},
|
ConfigKeyAuthSignupEnabled: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionAuth},
|
||||||
@@ -207,3 +244,21 @@ index 8595ea2a..621fd132 100644
|
|||||||
ConfigKeyIntegrationsUseGravatar: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionIntegrations},
|
ConfigKeyIntegrationsUseGravatar: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionIntegrations},
|
||||||
ConfigKeyOperationNewOwnerEnabled: {DefaultValue: "false", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionMisc},
|
ConfigKeyOperationNewOwnerEnabled: {DefaultValue: "false", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionMisc},
|
||||||
ConfigKeyDomainDefaultsPrefix + DomainConfigKeyCommentDeletionAuthor: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionComments},
|
ConfigKeyDomainDefaultsPrefix + DomainConfigKeyCommentDeletionAuthor: {DefaultValue: "true", Datatype: ConfigDatatypeBool, Section: DynConfigItemSectionComments},
|
||||||
|
diff --git a/internal/data/models.go b/internal/data/models.go
|
||||||
|
index 4561fad5..0b491724 100644
|
||||||
|
--- a/internal/data/models.go
|
||||||
|
+++ b/internal/data/models.go
|
||||||
|
@@ -74,9 +74,10 @@ func (sd SortDirection) ToOrderedExpression(ident string) exp.OrderedExpression
|
||||||
|
|
||||||
|
// FederatedIdentityProvider describes a federated identity provider
|
||||||
|
type FederatedIdentityProvider struct {
|
||||||
|
- ID models.FederatedIdpID // Provider ID
|
||||||
|
- Name string // Provider name
|
||||||
|
- GothName string // Name of the corresponding goth provider
|
||||||
|
+ ID models.FederatedIdpID // Provider ID
|
||||||
|
+ Name string // Provider name
|
||||||
|
+ GothName string // Name of the corresponding goth provider
|
||||||
|
+ SuperuserClaim string // Name of the OIDC claim for superusers
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToDTO converts this model into an API model
|
||||||
|
@@ -17,6 +17,7 @@ pkgs.dockerTools.buildImage {
|
|||||||
Env = [
|
Env = [
|
||||||
"HOST=0.0.0.0"
|
"HOST=0.0.0.0"
|
||||||
"PORT=8080"
|
"PORT=8080"
|
||||||
|
"CONFIG_FILE=/etc/comentario/config.yaml"
|
||||||
"SECRETS_FILE=/etc/comentario/secrets.yaml"
|
"SECRETS_FILE=/etc/comentario/secrets.yaml"
|
||||||
];
|
];
|
||||||
ExposedPorts = {
|
ExposedPorts = {
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
(patcher.fetchpatch {
|
(patcher.fetchpatch {
|
||||||
name = "feat: supports images";
|
name = "feat: supports images";
|
||||||
url = "https://github.com/SEIAROTg/quadlet-nix/compare/main...karaolidis:quadlet-nix:image.diff";
|
url = "https://github.com/SEIAROTg/quadlet-nix/compare/main...karaolidis:quadlet-nix:image.diff";
|
||||||
hash = "sha256-XLdOrSJ/gyLARGI0psBejtpX9Z2NSRTaUbFtBi8BxPw=";
|
hash = "sha256-8li8XuBV3+J0s3FACOyKP+ndffn8T/PQXq+UrIk2TAc=";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user