Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add userlog_global_notifications_secret #400

Merged
merged 8 commits into from
Oct 17, 2023
Merged

add userlog_global_notifications_secret #400

merged 8 commits into from
Oct 17, 2023

Conversation

case0sh
Copy link
Contributor

@case0sh case0sh commented Sep 20, 2023

Description

expose USERLOG_GLOBAL_NOTIFICATIONS_SECRET option for userlog deployment

Related Issue

How Has This Been Tested?

  • test environment: k8s, helm charts
  1. Need to change this options form false to true
features:
  basicAuthentication: true
  demoUsers: true
  1. Add your secret to k8s:
apiVersion: v1
kind: Secret
metadata:
  namespace: ocis
  name: foo
type: Opaque
data:
  notifications-secret: dmFsdWUtMg0KDQo=
kubectl get -n ocis secret foo -o jsonpath='{.data.notifications-secret}' | base64 --decode
echo dmFsdWUtMg0KDQo= | base64 --decode # value-2
  1. Add name of you secret globalNotificationsSecretRef: "foo"

  2. test case 1: Test directly

curl --insecure -X POST -H secret:dmFsdWUtMg0KDQo= -v -d '{"type":"deprovision", "data":{"deprovision_date": "2023-07-04T17:12:03Z"}}'http://localhost:8080/ocs/v2.php/apps/notifications/api/v1/notifications/global
  • test case 2: Test via proxy
# trigger global notification(admin)
curl --insecure -X POST  -u admin:password  -v -d '{"type":"deprovision", "data":{"deprovision_date": "2023-07-04T17:12:03Z"}}' https://ocis.kube.owncloud.test/ocs/v2.php/apps/notifications/api/v1/notifications/global

# delete global notification
curl --insecure -X DELETE  -u admin:password   -v -d '{"ids":["deprovision"]}' https://ocis.kube.owncloud.test/ocs/v2.php/apps/notifications/api/v1/notifications/global

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

@@ -26,7 +26,8 @@ spec:
{{- include "ocis.containerSecurityContext" . | nindent 10 }}
env:
{{- include "ocis.serviceRegistry" . | nindent 12 }}

- name: USERLOG_GLOBAL_NOTIFICATIONS_SECRET
value: {{ .Values.notificationsSecret | quote }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get this from a Secret please? See eg. here:

- name: AUTH_MACHINE_API_KEY
valueFrom:
secretKeyRef:
name: {{ include "secrets.machineAuthAPIKeySecret" . }}
key: machine-auth-api-key

@case0sh case0sh marked this pull request as ready for review October 16, 2023 09:30
Copy link
Contributor

@wkloucek wkloucek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notification as admin user

add notification

curl --insecure -X POST -u admin:<password> -v -d '{"type":"deprovision", "data":{"deprovision_date": "2023-07-04T17:12:03Z"}}' https://ocis.kube.owncloud.test/ocs/v2.php/apps/notifications/api/v1/notifications/global

-> works

remove notification

curl --insecure -X DELETE -u admin:<password> -v -d '{"ids":["deprovision"]}' https://ocis.kube.owncloud.test/ocs/v2.php/apps/notifications/api/v1/notifications/global

-> works

notification with secret

add notification

kubectl -n ocis exec deployment/userlog -- curl --insecure -X POST -H secret:<secret> -v -d '{"type":"deprovision", "data":{"deprovision_date": "2023-07-04T17:12:03Z"}}' http://localhost:8080/ocs/v2.php/apps/notifications/api/v1/notifications/global

-> this does not work for me

@case0sh could you please check if it works on your side and provide more information how you did it? I assumed that it needs to use the localhost:8080 from the userlog container, right? Did you really use the base64 encoded secret or the plaintext secret?

documentation

please also link the docs-ocis PR where you add information about the secret referenced in globalNotificationsSecretRef

@wkloucek
Copy link
Contributor

Actually -u secret:<secret> needs to be -H secret:<secret>

kubectl -n ocis exec deployment/userlog -- curl --insecure -X POST -H secret:<secret> -v -d '{"type":"deprovision", "data":{"deprovision_date": "2023-07-04T17:12:03Z"}}' http://localhost:8080/ocs/v2.php/apps/notifications/api/v1/notifications/global is working, as well as deleting the notification.

@case0sh case0sh requested a review from wkloucek October 17, 2023 10:30
@wkloucek wkloucek merged commit ebb8584 into master Oct 17, 2023
@delete-merged-branch delete-merged-branch bot deleted the userlog branch October 17, 2023 10:47
wkloucek added a commit that referenced this pull request Oct 18, 2023
* add userlog_global_notifications_secret (#400)

* add userlog_global_notifications_secret

* add secrets for userlog

* add secrets for userlog

* add secret options

* fix notifications secrets

* fix notifications secrets

* fix notifications secrets

* add docs

* pin latest ocis version

* allow to actually configure banned passwords

* generate documentation

---------

Co-authored-by: DanielY <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support USERLOG_GLOBAL_NOTIFICATIONS_SECRET
2 participants