diff --git a/changelog/unreleased/global-notifications-static-secret.md b/changelog/unreleased/gn-static-secret.md similarity index 75% rename from changelog/unreleased/global-notifications-static-secret.md rename to changelog/unreleased/gn-static-secret.md index 7110d5e0b7..9656756ad7 100644 --- a/changelog/unreleased/global-notifications-static-secret.md +++ b/changelog/unreleased/gn-static-secret.md @@ -1,4 +1,4 @@ -Enhancement: Allow calling the global notifications endpoints when knowing a static secret +Enhancement: Add static secret to gn endpoints The global notifications POST and DELETE endpoints (used only for deprovision notifications at the moment) can now be called by adding a static secret to the header. Admins can still call this endpoint without knowing the secret diff --git a/services/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index f781595383..887185b34e 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -38,6 +38,7 @@ type Config struct { EnableFederatedSharingOutgoing bool `yaml:"enable_federated_sharing_outgoing" env:"FRONTEND_ENABLE_FEDERATED_SHARING_OUTGOING" desc:"Changing this value is NOT supported. Enables support for outgoing federated sharing for clients. The backend behaviour is not changed."` SearchMinLength int `yaml:"search_min_length" env:"FRONTEND_SEARCH_MIN_LENGTH" desc:"Minimum number of characters to enter before a client should start a search for Share receivers. This setting can be used to customize the user experience if e.g too many results are displayed."` Edition string `yaml:"edition" env:"OCIS_EDITION;FRONTEND_EDITION"` + DisableSSE bool `yaml:"disable_sse" env:"OCIS_DISABLE_SSE,FRONTEND_DISABLE_SSE" desc:"When set to true, clients are informed that the Server-Sent Events endpoint is not accessible."` PublicURL string `yaml:"public_url" env:"OCIS_URL;FRONTEND_PUBLIC_URL" desc:"The public facing URL of the oCIS frontend."` diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index 993b9b855f..3383251c1d 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -192,7 +192,7 @@ func FrontendConfigFromStruct(cfg *config.Config) (map[string]interface{}, error "hostname": "", }, "support_url_signing": true, - "support_sse": true, + "support_sse": !cfg.DisableSSE, }, "graph": map[string]interface{}{ "personal_data_export": true, diff --git a/services/userlog/README.md b/services/userlog/README.md index ca686f19c9..250f92c869 100644 --- a/services/userlog/README.md +++ b/services/userlog/README.md @@ -36,7 +36,11 @@ Additionally to the oc10 API, the `userlog` service also provides an `/sse` (Ser ## Posting -The userlog service is able to store global messages that will be displayed in the Web UI to all users. These messages can only be activated and deleted by users with the `admin` role but not by ordinary users. If a user deletes the message in the Web UI, it reappears on reload. Global messages use the endpoint `/ocs/v2.php/apps/notifications/api/v1/notifications/global` and are activated by sending a `POST` request. Note that sending another `POST` request of the same type overwrites the previous one. For the time being, only the type `deprovision` is supported. +The userlog service is able to store global messages that will be displayed in the Web UI to all users. If a user deletes the message in the Web UI, it reappears on reload. Global messages use the endpoint `/ocs/v2.php/apps/notifications/api/v1/notifications/global` and are activated by sending a `POST` request. Note that sending another `POST` request of the same type overwrites the previous one. For the time being, only the type `deprovision` is supported. + +### Authentication + +`POST` and `DELETE` endpoints provide notifications to all users, therefore only certain users can access them. There are two different possiblities to authenticate for this endpoint. First, users with the `admin` role can always access the endpoints. However it is possible to define a static secret via the `USERLOG_GLOBAL_NOTIFICATIONS_SECRET`. Users knowing the secret can send a header containing it on their requests. Having the secret in the header bypasses the `admin` requirement. ### Deprovisioning @@ -46,7 +50,7 @@ Deprovision messages announce a deprovision text including a deprovision date of To delete events for an user, use a `DELETE` request to `ocs/v2.php/apps/notifications/api/v1/notifications` containing the IDs to delete. -Only users with the `admin` role can send a `DELETE` request to the `ocs/v2.php/apps/notifications/api/v1/notifications/global` endpoint to remove a global message, see the [Posting](#posting) section for more details.) +Sending a `DELETE` request to the `ocs/v2.php/apps/notifications/api/v1/notifications/global` endpoint to remove a global message is a restricted action, see the [Authentication](###authentication) section for more details.) ## Translations diff --git a/services/userlog/pkg/config/config.go b/services/userlog/pkg/config/config.go index 96836855fe..5c723d5be1 100644 --- a/services/userlog/pkg/config/config.go +++ b/services/userlog/pkg/config/config.go @@ -30,7 +30,7 @@ type Config struct { DisableSSE bool `yaml:"disable_sse" env:"OCIS_DISABLE_SSE,USERLOG_DISABLE_SSE" desc:"Disables server-sent events (sse). When disabled, clients will no longer be able to connect to the sse endpoint."` - GlobalNotificationsSecret string `yaml:"global_notifications_secret" env:"USERLOG_GLOBAL_NOTIFICATIONS_SECRET" desc:"The secret to secure the global notifications endpoint. Only users knowing that secret and system admins can call the global notifications POST/DELETE endpoints"` + GlobalNotificationsSecret string `yaml:"global_notifications_secret" env:"USERLOG_GLOBAL_NOTIFICATIONS_SECRET" desc:"The secret to secure the global notifications endpoint. Only system admins and users knowing that secret can call the global notifications POST/DELETE endpoints."` Context context.Context `yaml:"-"` }