mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-23 13:28:45 +00:00
feat(api): return allowed_languages (#11553)
# Which Problems Are Solved While Zitadel provides a possibility to restrict certain languages to be used, the corresponding list could not be retrieved in the settings service (v2). This blocked login v2 implementations from respecting the list and they would always use all available languages. # How the Problems Are Solved - Retrieve the list when checking the instance and pass it into the context. - Return it as part of the existing `GetGeneralSettingsResponse` - This allows us to remove an additional query in some other cases / endpoints. # Additional Changes none # Additional Context - required for https://github.com/zitadel/zitadel/pull/11372 - backport to v4.x --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Marco A. <[email protected]>
This commit is contained in:
co-authored by
Copilot
Marco A.
parent
ceffb9c536
commit
b0609aa861
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
|
||||
target_domain "github.com/zitadel/zitadel/internal/execution/target"
|
||||
@@ -472,6 +473,7 @@ type authzInstance struct {
|
||||
ExternalDomains database.TextArray[string] `json:"external_domains,omitempty"`
|
||||
TrustedDomains database.TextArray[string] `json:"trusted_domains,omitempty"`
|
||||
ExecutionTargets target_domain.Router `json:"execution_targets,omitzero"`
|
||||
AllowedLangs []language.Tag `json:"allowed_langs,omitempty"`
|
||||
}
|
||||
|
||||
type csp struct {
|
||||
@@ -499,6 +501,10 @@ func (i *authzInstance) DefaultLanguage() language.Tag {
|
||||
return i.DefaultLang
|
||||
}
|
||||
|
||||
func (i *authzInstance) AllowedLanguages() []language.Tag {
|
||||
return i.AllowedLangs
|
||||
}
|
||||
|
||||
func (i *authzInstance) DefaultOrganisationID() string {
|
||||
return i.DefaultOrgID
|
||||
}
|
||||
@@ -566,6 +572,7 @@ func scanAuthzInstance() (*authzInstance, func(row *sql.Row) error) {
|
||||
block sql.NullBool
|
||||
features []byte
|
||||
executionTargetsBytes []byte
|
||||
allowedLanguages database.TextArray[string]
|
||||
)
|
||||
err := row.Scan(
|
||||
&instance.ID,
|
||||
@@ -583,6 +590,7 @@ func scanAuthzInstance() (*authzInstance, func(row *sql.Row) error) {
|
||||
&instance.ExternalDomains,
|
||||
&instance.TrustedDomains,
|
||||
&executionTargetsBytes,
|
||||
&allowedLanguages,
|
||||
)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return zerrors.ThrowNotFound(nil, "QUERY-1kIjX", "Errors.Instance.NotFound")
|
||||
@@ -611,6 +619,7 @@ func scanAuthzInstance() (*authzInstance, func(row *sql.Row) error) {
|
||||
}
|
||||
instance.ExecutionTargets = target_domain.NewRouter(targets)
|
||||
}
|
||||
instance.AllowedLangs = domain.StringsToLanguages(allowedLanguages)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ select
|
||||
f.features,
|
||||
ed.domains as external_domains,
|
||||
td.domains as trusted_domains,
|
||||
et.execution_targets
|
||||
et.execution_targets,
|
||||
r.allowed_languages
|
||||
from domain d
|
||||
join projections.instances i on i.id = d.instance_id
|
||||
left join projections.security_policies2 s on i.id = s.instance_id
|
||||
@@ -81,4 +82,5 @@ left join projections.limits l on i.id = l.instance_id
|
||||
left join features f on i.id = f.instance_id
|
||||
left join external_domains ed on i.id = ed.instance_id
|
||||
left join trusted_domains td on i.id = td.instance_id
|
||||
left join execution_targets et on i.id = et.instance_id;
|
||||
left join execution_targets et on i.id = et.instance_id
|
||||
left join projections.restrictions2 r on i.id = r.instance_id;
|
||||
|
||||
@@ -63,7 +63,8 @@ select
|
||||
f.features,
|
||||
ed.domains as external_domains,
|
||||
td.domains as trusted_domains,
|
||||
et.execution_targets
|
||||
et.execution_targets,
|
||||
r.allowed_languages
|
||||
from projections.instances i
|
||||
left join projections.security_policies2 s on i.id = s.instance_id
|
||||
left join projections.limits l on i.id = l.instance_id
|
||||
@@ -71,4 +72,5 @@ left join features f on i.id = f.instance_id
|
||||
left join external_domains ed on i.id = ed.instance_id
|
||||
left join trusted_domains td on i.id = td.instance_id
|
||||
left join execution_targets et on i.id = et.instance_id
|
||||
left join projections.restrictions2 r on i.id = r.instance_id
|
||||
where i.id = $1;
|
||||
|
||||
Reference in New Issue
Block a user