chore: update get request origin
This commit is contained in:
parent
3b089eeae3
commit
c1da87a819
1 changed files with 10 additions and 4 deletions
|
|
@ -248,11 +248,17 @@ func (s *APIV2Service) buildAccessTokenCookie(ctx context.Context, accessToken s
|
||||||
} else {
|
} else {
|
||||||
attrs = append(attrs, "Expires="+expireTime.Format(time.RFC1123))
|
attrs = append(attrs, "Expires="+expireTime.Format(time.RFC1123))
|
||||||
}
|
}
|
||||||
workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
|
|
||||||
if err != nil {
|
md, ok := metadata.FromIncomingContext(ctx)
|
||||||
return "", errors.Wrap(err, "failed to get workspace setting")
|
if !ok {
|
||||||
|
return "", errors.New("failed to get metadata from context")
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(workspaceGeneralSetting.InstanceUrl, "https://") {
|
var origin string
|
||||||
|
for _, v := range md.Get("origin") {
|
||||||
|
origin = v
|
||||||
|
}
|
||||||
|
isHTTPS := strings.HasPrefix(origin, "https://")
|
||||||
|
if isHTTPS {
|
||||||
attrs = append(attrs, "SameSite=None")
|
attrs = append(attrs, "SameSite=None")
|
||||||
attrs = append(attrs, "Secure")
|
attrs = append(attrs, "Secure")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue