Skip to content

Commit

Permalink
emails: use correct k8s namespace and component prefix in templates
Browse files Browse the repository at this point in the history
Use the correct Kubernetes namespace and component prefix when building
`kubectl` commands in the token request email template.

Closes #615
  • Loading branch information
mdonadoni committed Aug 29, 2023
1 parent 44ce837 commit 6cce102
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Version 0.9.1 (UNRELEASED)
- Changes the system status report to simplify and clarify the disk usage summary.
- Fixes GitLab integration to automatically redirect the user to the correct URL when the access request is accepted.
- Fixes authentication flow to correctly deny access to past revoked tokens in case the same user has also other new active tokens.
- Fixes the email templates to show the correct ``kubectl`` commands when REANA is deployed inside a non-default namespace or with a custom component name prefix.
- Adds logic to support SSO with third-party Keycloak authentication services to ``config.py``.

Version 0.9.0 (2023-01-19)
Expand Down
6 changes: 6 additions & 0 deletions reana_server/rest/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from bravado.exception import HTTPError
from flask import Blueprint, jsonify
from reana_db.models import AuditLogAction
from reana_commons.config import (
REANA_COMPONENT_PREFIX,
REANA_INFRASTRUCTURE_KUBERNETES_NAMESPACE,
)
from reana_commons.email import send_email
from reana_commons.errors import REANAEmailNotificationError

Expand Down Expand Up @@ -319,6 +323,8 @@ def request_token(user):
user_data=user_data,
user_email=user.email,
reana_hostname=REANA_HOSTNAME,
namespace=REANA_INFRASTRUCTURE_KUBERNETES_NAMESPACE,
component_prefix=REANA_COMPONENT_PREFIX,
)
try:
send_email(ADMIN_EMAIL, email_subject, email_body)
Expand Down
6 changes: 3 additions & 3 deletions reana_server/templates/emails/token_request.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ There is a new access token request for {{ reana_hostname }}:

To obtain administration credentials, please run:

$ export REANA_ACCESS_TOKEN=$(kubectl get secret reana-admin-access-token -o json | jq -r '.data | map_values(@base64d) | .ADMIN_ACCESS_TOKEN')
$ export REANA_ACCESS_TOKEN=$(kubectl get -n {{ namespace }} secret {{ component_prefix }}-admin-access-token -o json | jq -r '.data.ADMIN_ACCESS_TOKEN' | base64 --decode)

To grant the user token, please run:

$ kubectl exec -i -t deployment/reana-server -- flask reana-admin token-grant -e {{ user_email }} --admin-access-token $REANA_ACCESS_TOKEN
$ kubectl exec -n {{ namespace }} -i -t deployment/{{ component_prefix }}-server -- flask reana-admin token-grant -e {{ user_email }} --admin-access-token $REANA_ACCESS_TOKEN

To reject the user token, please run:

$ kubectl exec -i -t deployment/reana-server -- flask reana-admin token-revoke -e {{ user_email }} --admin-access-token $REANA_ACCESS_TOKEN
$ kubectl exec -n {{ namespace }} -i -t deployment/{{ component_prefix }}-server -- flask reana-admin token-revoke -e {{ user_email }} --admin-access-token $REANA_ACCESS_TOKEN

Thanks,

Expand Down

0 comments on commit 6cce102

Please sign in to comment.