Skip to content

Commit

Permalink
ingore session sync in wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 29, 2023
1 parent fc2eda5 commit 023e7ac
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/api/authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,30 +295,30 @@ func (a *AuthN) Callback(ctx *gear.Context) error {

http.SetCookie(ctx.Res, sessCookie)
next := a.authURL.GenNextUrl(nextURL, 200, "")
if isInWechat {
next = strings.Replace(next, a.cookie.Domain, a.cookie.WeChatDomain, 2)
obj := &cose.Mac0Message[key.IntMap]{
Unprotected: cose.Headers{},
Payload: key.IntMap{
0: time.Now().Add(20 * time.Second).Unix(),
1: res.SID.String(),
2: res.Session,
3: next,
},
}

if err := obj.Compute(a.stateMACer, nil); err == nil {
if data, err := cbor.Marshal(obj); err == nil {
reqUrl := &url.URL{
Scheme: "https",
Host: strings.Replace(ctx.Host, a.cookie.WeChatDomain, a.cookie.Domain, 1),
Path: "/sync_session",
RawQuery: "sess=" + base64.RawURLEncoding.EncodeToString(data),
}
next = reqUrl.String()
}
}
}
// if isInWechat {
// next = strings.Replace(next, a.cookie.Domain, a.cookie.WeChatDomain, 2)
// obj := &cose.Mac0Message[key.IntMap]{
// Unprotected: cose.Headers{},
// Payload: key.IntMap{
// 0: time.Now().Add(20 * time.Second).Unix(),
// 1: res.SID.String(),
// 2: res.Session,
// 3: next,
// },
// }
// 被微信拦截了
// if err := obj.Compute(a.stateMACer, nil); err == nil {
// if data, err := cbor.Marshal(obj); err == nil {
// reqUrl := &url.URL{
// Scheme: "https",
// Host: strings.Replace(ctx.Host, a.cookie.WeChatDomain, a.cookie.Domain, 1),
// Path: "/sync_session",
// RawQuery: "sess=" + base64.RawURLEncoding.EncodeToString(data),
// }
// next = reqUrl.String()
// }
// }
// }

logging.SetTo(ctx, "redirect_url", next)
return ctx.Redirect(next)
Expand Down

0 comments on commit 023e7ac

Please sign in to comment.