Sfoglia il codice sorgente

New verification method for DOI requests

Instead of sending the user's token in encrypted form, we send the same
information as the other URL parameters (username and repo path) in
encrypted form for verification.
Achilleas Koutsou 6 anni fa
parent
commit
19ee3ece22
1 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 8 5
      routes/doi.go

+ 8 - 5
routes/doi.go

@@ -19,8 +19,11 @@ func RequestDOI(c *context.Context) {
 		c.Status(http.StatusUnauthorized)
 		c.Status(http.StatusUnauthorized)
 		return
 		return
 	}
 	}
-	token := c.GetCookie(setting.SessionConfig.CookieName)
-	token, err := encrypt([]byte(setting.DOI.Key), token)
+
+	repo := c.Repo.Repository.FullName()
+	username := c.User.Name
+	// verification := c.GetCookie(setting.SessionConfig.CookieName)
+	verification, err := encrypt([]byte(setting.DOI.Key), repo+username)
 	if err != nil {
 	if err != nil {
 		log.Error(2, "Could not encrypt secret key: %s", err)
 		log.Error(2, "Could not encrypt secret key: %s", err)
 		c.Status(http.StatusInternalServerError)
 		c.Status(http.StatusInternalServerError)
@@ -32,9 +35,9 @@ func RequestDOI(c *context.Context) {
 	}
 	}
 
 
 	params := url.Values{}
 	params := url.Values{}
-	params.Add("repo", c.Repo.Repository.FullName())
-	params.Add("user", c.User.Name)
-	params.Add("token", token)
+	params.Add("repo", repo)
+	params.Add("user", username)
+	params.Add("verification", verification)
 	doiurl.RawQuery = params.Encode()
 	doiurl.RawQuery = params.Encode()
 	target, _ := url.PathUnescape(doiurl.String())
 	target, _ := url.PathUnescape(doiurl.String())
 	log.Trace(target)
 	log.Trace(target)