filter user e-mail in graph/user requests

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2024-04-02 16:36:23 +02:00
parent 68756ba927
commit 59fab4ae5a
4 changed files with 12 additions and 3 deletions
@@ -5,3 +5,4 @@ the sharee search. This is the ocis side which adds an suiting config option to
https://github.com/owncloud/ocis/issues/8726
https://github.com/cs3org/reva/pull/4603
https://github.com/owncloud/ocis/pull/8764
+2 -1
View File
@@ -2,5 +2,6 @@ package config
// TokenManager is the config for using the reva token manager
type TokenManager struct {
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;GRAPH_JWT_SECRET" desc:"The secret to mint and validate jwt tokens." introductionVersion:"pre5.0"`
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;GRAPH_JWT_SECRET" desc:"The secret to mint and validate jwt tokens." introductionVersion:"pre5.0"`
ShowUserEmailInResults bool `yaml:"mask_user_email" env:"OCIS_SHOW_USER_EMAIL_IN_RESULTS" desc:"Mask user email addresses in responses." introductionVersion:"5.1"`
}
+8 -1
View File
@@ -279,9 +279,12 @@ func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {
finalUsers[i] = &libregraph.User{
Id: u.Id,
DisplayName: u.DisplayName,
Mail: u.Mail,
UserType: u.UserType,
}
if g.config.TokenManager.ShowUserEmailInResults {
finalUsers[i].Mail = u.Mail
}
}
users = finalUsers
}
@@ -545,6 +548,10 @@ func (g Graph) GetUser(w http.ResponseWriter, r *http.Request) {
}
}
if !g.config.TokenManager.ShowUserEmailInResults {
user.Mail = nil
}
render.Status(r, http.StatusOK)
render.JSON(w, r, user)
}
+1 -1
View File
@@ -3,5 +3,5 @@ package config
// TokenManager is the config for using the reva token manager
type TokenManager struct {
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;OCS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens." introductionVersion:"pre5.0"`
ShowUserEmailInResults bool `yaml:"mask_user_email" env:"OCS_SHOW_USER_EMAIL_IN_RESULTS" desc:"Mask user email addresses in responses." introductionVersion:"5.1"`
ShowUserEmailInResults bool `yaml:"mask_user_email" env:"OCIS_SHOW_USER_EMAIL_IN_RESULTS" desc:"Mask user email addresses in responses." introductionVersion:"5.1"`
}