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

OCM: Pass the link to the meshdirectory service in token mail #1002

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/unreleased/ocm-token-mail-meshdir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Enhancement: Pass the link to the meshdirectory service in token mail.

Currently, we just forward the token and the original user's domain when
forwarding an OCM invite token and expect the user to frame the forward invite
URL. This PR instead passes the link to the meshdirectory service, from where
the user can pick the provider they want to accept the invite with.

https://github.com/cs3org/reva/pull/1002
https://github.com/sciencemesh/sciencemesh/issues/139
17 changes: 14 additions & 3 deletions internal/http/services/ocmd/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ import (
)

type invitesHandler struct {
smtpCredentials *smtpclient.SMTPCredentials
gatewayAddr string
smtpCredentials *smtpclient.SMTPCredentials
gatewayAddr string
meshDirectoryURL string
}

func (h *invitesHandler) init(c *Config) {
h.gatewayAddr = c.GatewaySvc
h.smtpCredentials = smtpclient.NewSMTPCredentials(c.SMTPCredentials)
h.meshDirectoryURL = c.MeshDirectoryURL
}

func (h *invitesHandler) Handler() http.Handler {
Expand Down Expand Up @@ -90,7 +92,9 @@ func (h *invitesHandler) generateInviteToken(w http.ResponseWriter, r *http.Requ
subject := fmt.Sprintf("ScienceMesh: %s wants to collaborate with you", usr.DisplayName)
body := "Hi,\n\n" +
usr.DisplayName + " (" + usr.Mail + ") wants to start sharing OCM resources with you. " +
"To accept the invite, please use the following details:\n" +
"To accept the invite, please visit the following URL:\n" +
h.meshDirectoryURL + "?token=" + token.InviteToken.Token + "&providerDomain=" + usr.Id.Idp + "\n\n" +
"Alternatively, you can visit your mesh provider and use the following details:\n" +
"Token: " + token.InviteToken.Token + "\n" +
"ProviderDomain: " + usr.Id.Idp + "\n\n" +
"Best,\nThe ScienceMesh team"
Expand Down Expand Up @@ -164,6 +168,13 @@ func (h *invitesHandler) forwardInvite(w http.ResponseWriter, r *http.Request) {
return
}

_, err = w.Write([]byte("Accepted invite from: " + r.FormValue("providerDomain")))
if err != nil {
WriteError(w, r, APIErrorServerError, "error writing token data", err)
return
}
w.WriteHeader(http.StatusOK)

log.Info().Msgf("Invite forwarded to: %s", r.FormValue("providerDomain"))
}

Expand Down
11 changes: 6 additions & 5 deletions internal/http/services/ocmd/ocmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import (

// Config holds the config options that need to be passed down to all ocdav handlers
type Config struct {
SMTPCredentials *smtpclient.SMTPCredentials `mapstructure:"smtp_credentials"`
Prefix string `mapstructure:"prefix"`
Host string `mapstructure:"host"`
GatewaySvc string `mapstructure:"gatewaysvc"`
Config configData `mapstructure:"config"`
SMTPCredentials *smtpclient.SMTPCredentials `mapstructure:"smtp_credentials"`
Prefix string `mapstructure:"prefix"`
Host string `mapstructure:"host"`
GatewaySvc string `mapstructure:"gatewaysvc"`
MeshDirectoryURL string `mapstructure:"mesh_directory_url"`
Config configData `mapstructure:"config"`
}

func (c *Config) init() {
Expand Down