mirror of
https://github.com/documize/community.git
synced 2025-07-23 23:29:42 +02:00
secure aurh provider secrets
This commit is contained in:
parent
22e9d34d7a
commit
8852a7b333
2 changed files with 33 additions and 0 deletions
|
@ -439,6 +439,36 @@ func KeycloakUsers(c keycloakConfig) (users []entity.User, err error) {
|
||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StripAuthSecrets removes sensitive data from auth provider configuration
|
||||||
|
func StripAuthSecrets(provider, config string) string {
|
||||||
|
switch provider {
|
||||||
|
case "documize":
|
||||||
|
return config
|
||||||
|
break
|
||||||
|
case "keycloak":
|
||||||
|
c := keycloakConfig{}
|
||||||
|
err := json.Unmarshal([]byte(config), &c)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("StripAuthSecrets", err)
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
c.AdminPassword = ""
|
||||||
|
c.AdminUser = ""
|
||||||
|
c.PublicKey = ""
|
||||||
|
|
||||||
|
j, err := json.Marshal(c)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("StripAuthSecrets", err)
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(j)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
// Data received via Keycloak client library
|
// Data received via Keycloak client library
|
||||||
type keycloakAuthRequest struct {
|
type keycloakAuthRequest struct {
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
|
|
|
@ -49,6 +49,9 @@ func GetMeta(w http.ResponseWriter, r *http.Request) {
|
||||||
data.Edition = Product.License.Edition
|
data.Edition = Product.License.Edition
|
||||||
data.Valid = Product.License.Valid
|
data.Valid = Product.License.Valid
|
||||||
|
|
||||||
|
// Strip secrets
|
||||||
|
data.AuthConfig = StripAuthSecrets(org.AuthProvider, org.AuthConfig)
|
||||||
|
|
||||||
json, err := json.Marshal(data)
|
json, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeJSONMarshalError(w, method, "meta", err)
|
writeJSONMarshalError(w, method, "meta", err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue