mirror of https://github.com/h44z/wg-portal.git
				
				
				
			add HttpOnly and Secure flag to cookie store (#39)
This commit is contained in:
		
							parent
							
								
									929c95f9ae
								
							
						
					
					
						commit
						b4bd2b35e2
					
				|  | @ -116,7 +116,16 @@ func (s *Server) Setup(ctx context.Context) error { | ||||||
| 		s.server.Use(ginlogrus.Logger(logrus.StandardLogger())) | 		s.server.Use(ginlogrus.Logger(logrus.StandardLogger())) | ||||||
| 	} | 	} | ||||||
| 	s.server.Use(gin.Recovery()) | 	s.server.Use(gin.Recovery()) | ||||||
| 	s.server.Use(sessions.Sessions("authsession", memstore.NewStore([]byte(s.config.Core.SessionSecret)))) | 
 | ||||||
|  | 	// Authentication cookies
 | ||||||
|  | 	cookieStore := memstore.NewStore([]byte(s.config.Core.SessionSecret)) | ||||||
|  | 	cookieStore.Options(sessions.Options{ | ||||||
|  | 		Path:     "/", | ||||||
|  | 		MaxAge:   86400, // auth session is valid for 1 day
 | ||||||
|  | 		Secure:   strings.HasPrefix(s.config.Core.ExternalUrl, "https"), | ||||||
|  | 		HttpOnly: true, | ||||||
|  | 	}) | ||||||
|  | 	s.server.Use(sessions.Sessions("authsession", cookieStore)) | ||||||
| 	s.server.SetFuncMap(template.FuncMap{ | 	s.server.SetFuncMap(template.FuncMap{ | ||||||
| 		"formatBytes": common.ByteCountSI, | 		"formatBytes": common.ByteCountSI, | ||||||
| 		"urlEncode":   url.QueryEscape, | 		"urlEncode":   url.QueryEscape, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue