* feat(invitations): configurable Keycloak actions + working ocis_full SMTP The invitations service already triggers Keycloak execute-actions-email after provisioning a guest (service.Invite -> backend.SendMail -> gocloak.ExecuteActionsEmail). Two things still limited it: - The required actions were hardcoded to UPDATE_PASSWORD,VERIFY_EMAIL. They are now configurable via INVITATIONS_KEYCLOAK_EXECUTE_ACTIONS (comma-separated, same default). Unknown actions are logged and skipped, and the service falls back to the defaults if none remain valid so a guest always has a setup path. - The Keycloak realm shipped with the ocis_full example had an empty smtpServer, so Keycloak silently dropped every mail it tried to send, including the guest invitation mail. The realm now points SMTP at the bundled mailpit (mailserver:1025). Verified: execute-actions-email delivers to mailpit against the ocis_full realm; go test ./services/invitations/... ./ocis-pkg/keycloak/... -race passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: David Walter <david.walter@kiteworks.com> * fix(invitations): return the created user as invitedUser in the response service.Invite echoed the request body unchanged, leaving the invitedUser relation of the Graph invitation response empty, so a client could not learn the identity of the guest that was just created. The keycloak backend now records the created user (OWNCLOUD_ID, email, user type) on the invitation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: David Walter <david.walter@kiteworks.com> * refactor(invitations): pass Keycloak actions through verbatim (no allowlist) Address review (@kobergj): the configured execute-actions no longer need to match a hardcoded enum. UserAction is now a string type passed to Keycloak as-is, so operators can configure any required action their Keycloak supports without oCIS keeping a list in sync. The convenience constants remain, the default (UPDATE_PASSWORD, VERIFY_EMAIL) is unchanged, and validation is left to Keycloak. Removes UserActionFromString and the two lookup maps. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: David Walter <david.walter@kiteworks.com> --------- Signed-off-by: David Walter <david.walter@kiteworks.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
96 lines
2.5 KiB
Go
96 lines
2.5 KiB
Go
package defaults
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/owncloud/ocis/v2/services/invitations/pkg/config"
|
|
)
|
|
|
|
func FullDefaultConfig() *config.Config {
|
|
cfg := DefaultConfig()
|
|
EnsureDefaults(cfg)
|
|
Sanitize(cfg)
|
|
return cfg
|
|
}
|
|
|
|
func DefaultConfig() *config.Config {
|
|
return &config.Config{
|
|
Debug: config.Debug{
|
|
Addr: "127.0.0.1:9269",
|
|
Token: "",
|
|
Pprof: false,
|
|
Zpages: false,
|
|
},
|
|
HTTP: config.HTTP{
|
|
Addr: "127.0.0.1:9265",
|
|
Root: "/graph/v1.0",
|
|
Namespace: "com.owncloud.web",
|
|
CORS: config.CORS{
|
|
AllowedOrigins: []string{"https://localhost:9200"},
|
|
},
|
|
},
|
|
Service: config.Service{
|
|
Name: "invitations",
|
|
},
|
|
Keycloak: config.Keycloak{
|
|
BasePath: "",
|
|
ClientID: "",
|
|
ClientSecret: "",
|
|
ClientRealm: "",
|
|
UserRealm: "",
|
|
ExecuteActions: []string{"UPDATE_PASSWORD", "VERIFY_EMAIL"},
|
|
},
|
|
}
|
|
}
|
|
|
|
func EnsureDefaults(cfg *config.Config) {
|
|
// provide with defaults for shared logging, since we need a valid destination address for "envdecode".
|
|
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
|
|
cfg.Log = &config.Log{
|
|
Level: cfg.Commons.Log.Level,
|
|
Pretty: cfg.Commons.Log.Pretty,
|
|
Color: cfg.Commons.Log.Color,
|
|
File: cfg.Commons.Log.File,
|
|
}
|
|
} else if cfg.Log == nil {
|
|
cfg.Log = &config.Log{}
|
|
}
|
|
// provide with defaults for shared tracing, since we need a valid destination address for "envdecode".
|
|
if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil {
|
|
cfg.Tracing = &config.Tracing{
|
|
Enabled: cfg.Commons.Tracing.Enabled,
|
|
Type: cfg.Commons.Tracing.Type,
|
|
Endpoint: cfg.Commons.Tracing.Endpoint,
|
|
Collector: cfg.Commons.Tracing.Collector,
|
|
}
|
|
} else if cfg.Tracing == nil {
|
|
cfg.Tracing = &config.Tracing{}
|
|
}
|
|
|
|
if cfg.Commons != nil {
|
|
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
|
|
}
|
|
|
|
if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil {
|
|
cfg.TokenManager = &config.TokenManager{
|
|
JWTSecret: cfg.Commons.TokenManager.JWTSecret,
|
|
}
|
|
} else if cfg.TokenManager == nil {
|
|
cfg.TokenManager = &config.TokenManager{}
|
|
}
|
|
|
|
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
|
|
(cfg.HTTP.CORS.AllowedOrigins == nil ||
|
|
len(cfg.HTTP.CORS.AllowedOrigins) == 1 &&
|
|
cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") {
|
|
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
|
|
}
|
|
}
|
|
|
|
func Sanitize(cfg *config.Config) {
|
|
// sanitize config
|
|
if cfg.HTTP.Root != "/" {
|
|
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
|
|
}
|
|
}
|