package web import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" // SSOOption is one provider on the chooser page. type SSOOption struct { Name string URL string } templ SSOChooser(p Page, opts []SSOOption) { @authShell(p) {

{ i18n.T(ctx, "auth.signup.to_login") }

} } // SSOProvider is a provider row on the settings page. type SSOProvider struct { ID string Name string Issuer string ClientID string HasSecret bool AllowedDomains string AutoProvision bool Enabled bool } // SSOSettings is the data of the organization SSO page. type SSOSettings struct { Providers []SSOProvider RedirectURL string LoginURL string } templ SSOSettingsPage(p Page, me Me, s SSOSettings) { @consoleShell(p, me) {

{ i18n.T(ctx, "sso.settings.title") }

{ i18n.T(ctx, "sso.settings.intro") }

{ i18n.T(ctx, "sso.settings.redirect_url") }
{ s.RedirectURL }
{ i18n.T(ctx, "sso.settings.login_url") }
{ s.LoginURL }
if len(s.Providers) > 0 { for _, pr := range s.Providers { }
{ i18n.T(ctx, "sso.field.name") } { i18n.T(ctx, "sso.field.issuer") } { i18n.T(ctx, "sso.field.auto_provision") } { i18n.T(ctx, "sso.field.enabled") }
{ pr.Name } { pr.Issuer } @yesNo(pr.AutoProvision) @yesNo(pr.Enabled)
{ i18n.T(ctx, "sso.action.edit") }
@ssoForm(pr, "put", "/org/sso/"+pr.ID)
}

{ i18n.T(ctx, "sso.settings.add") }

@ssoForm(SSOProvider{Enabled: true}, "post", "/org/sso")
} } templ yesNo(v bool) { if v { ● { i18n.T(ctx, "common.yes") } } else { ● { i18n.T(ctx, "common.no") } } } templ ssoForm(pr SSOProvider, method, action string) {
@formError() @valueField(i18n.T(ctx, "sso.field.name"), "name", pr.Name, "", true) @valueField(i18n.T(ctx, "sso.field.issuer"), "issuer", pr.Issuer, "https://login.example.com/realms/acme", true) @valueField(i18n.T(ctx, "sso.field.client_id"), "client_id", pr.ClientID, "", true) @checkbox(i18n.T(ctx, "sso.field.auto_provision"), "auto_provision", pr.AutoProvision) @checkbox(i18n.T(ctx, "sso.field.enabled"), "enabled", pr.Enabled) @submit(i18n.T(ctx, "common.save"))
} templ valueField(label, name, value, placeholder string, required bool) { } templ checkbox(label, name string, checked bool) { }