From 822ef7df341dc0ece7aaa3baa4ff2416ee42ebb5 Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 27 Jun 2018 19:32:01 -0500 Subject: [PATCH] fix auth url spec --- README.md | 2 +- backend/app/rest/auth/provider.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 50bb93bf..960df529 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ Also script can uses `url` property from `remark_config` object, or `window.loca ### Authorization -* `GET /auth/{provider}/login?from=http://url&session=1` - perform "social" login with one of supported providers and redirect to `url`. Presence of `session` (any non-zero value) change the default cookie expiration and makes them session-only. +* `GET /auth/{provider}/login?from=http://url&site=site_id&session=1` - perform "social" login with one of supported providers and redirect to `url`. Presence of `session` (any non-zero value) change the default cookie expiration and makes them session-only. * `GET /auth/logout` - logout ```go diff --git a/backend/app/rest/auth/provider.go b/backend/app/rest/auth/provider.go index 1e17eda3..40946429 100644 --- a/backend/app/rest/auth/provider.go +++ b/backend/app/rest/auth/provider.go @@ -107,7 +107,7 @@ func (p Provider) loginHandler(w http.ResponseWriter, r *http.Request) { // return login url loginURL := p.conf.AuthCodeURL(state) - log.Printf("[DEBUG] login url %s", loginURL) + log.Printf("[DEBUG] login url %s, claims=%+v", loginURL, claims) http.Redirect(w, r, loginURL, http.StatusFound) } @@ -164,7 +164,7 @@ func (p Provider) authHandler(w http.ResponseWriter, r *http.Request) { u = p.setPermissions(u, oauthClaims.SiteID) u = p.setAvatar(u) - authClaims := &CustomClaims{ + claims := &CustomClaims{ User: &u, StandardClaims: jwt.StandardClaims{ Issuer: "remark42", @@ -173,7 +173,7 @@ func (p Provider) authHandler(w http.ResponseWriter, r *http.Request) { SessionOnly: oauthClaims.SessionOnly, } - if err = p.JwtService.Set(w, authClaims, oauthClaims.SessionOnly); err != nil { + if err = p.JwtService.Set(w, claims, oauthClaims.SessionOnly); err != nil { rest.SendErrorJSON(w, r, http.StatusInternalServerError, err, "failed to save user info") return } @@ -205,6 +205,7 @@ func (p Provider) setPermissions(u store.User, siteID string) store.User { u.Admin = p.PermissionChecker.IsAdmin(u.ID) u.Verified = p.PermissionChecker.IsVerified(siteID, u.ID) u.Blocked = p.PermissionChecker.IsBlocked(siteID, u.ID) + log.Printf("[DEBUG] set permissions for user %s, site %s - %+v", u.ID, siteID, u) return u }