func()

in internal/auth/session.go [45:75]


func (a *Auth) getSessionFromStore(r *http.Request) (*hostSession, error) {
	session, err := a.store.Get(r, "gitlab-pages")

	if session != nil {
		namespaceInPath := a.getNamespaceInPath(r)

		// Cookie just for this domain
		session.Options.Path = "/" + namespaceInPath
		session.Options.HttpOnly = true
		session.Options.Secure = request.IsHTTPS(r)
		if !request.IsHTTPS(r) {
			session.Options.SameSite = http.SameSiteDefaultMode
		}
		session.Options.MaxAge = int(a.cookieSessionTimeout.Seconds())

		if session.Values[sessionHostKey] == nil || session.Values[sessionHostKey] != r.Host {
			logRequest(r).WithFields(log.Fields{
				"Session host":      session.Values[sessionHostKey],
				"Request host":      r.Host,
				"Namespace in path": namespaceInPath,
			}).Info("Resetting session values")

			session.Values = make(map[interface{}]interface{})
		}
		if len(namespaceInPath) > 0 {
			session.Values[namespaceInPathKey] = namespaceInPath
		}
	}

	return &hostSession{session}, err
}