remove useless isSecure dyn attr for cookies
This commit is contained in:
@@ -67,7 +67,7 @@ type Session struct {
|
||||
expirationTime time.Time
|
||||
}
|
||||
|
||||
func (s *Session) GenerateCookie(isSecure bool) *http.Cookie {
|
||||
func (s *Session) GenerateCookie() *http.Cookie {
|
||||
s.l.RLock()
|
||||
defer s.l.RUnlock()
|
||||
|
||||
@@ -75,7 +75,7 @@ func (s *Session) GenerateCookie(isSecure bool) *http.Cookie {
|
||||
Name: "session_id",
|
||||
Value: s.sessionID,
|
||||
HttpOnly: true,
|
||||
Secure: isSecure,
|
||||
Secure: true,
|
||||
Expires: s.expirationTime,
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,6 @@ func (s *Session) GenerateCookie(isSecure bool) *http.Cookie {
|
||||
type IAuthenticate interface {
|
||||
IsLogged(r *http.Request) bool
|
||||
Authenticate(username, password string) (*Session, error)
|
||||
IsSecure() bool
|
||||
}
|
||||
|
||||
var _ IAuthenticate = (*Authentication)(nil)
|
||||
@@ -95,17 +94,15 @@ type Authentication struct {
|
||||
fnCancel context.CancelFunc
|
||||
|
||||
sessions map[string]*Session
|
||||
isSecure bool
|
||||
}
|
||||
|
||||
func NewAuthentication(ctx context.Context, isSecure bool) *Authentication {
|
||||
func NewAuthentication(ctx context.Context) *Authentication {
|
||||
ctxChild, fnCancel := context.WithCancel(ctx)
|
||||
|
||||
s := &Authentication{
|
||||
ctx: ctxChild,
|
||||
fnCancel: fnCancel,
|
||||
sessions: map[string]*Session{},
|
||||
isSecure: isSecure,
|
||||
}
|
||||
s.purgeWorker()
|
||||
|
||||
@@ -146,10 +143,6 @@ func (a *Authentication) purgeWorker() {
|
||||
}()
|
||||
}
|
||||
|
||||
func (a *Authentication) IsSecure() bool {
|
||||
return a.isSecure
|
||||
}
|
||||
|
||||
func (a *Authentication) Stop() {
|
||||
a.fnCancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user