-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement shallow remember me #212
Comments
How to enter in the "login" phase of authboss? Is there any hook? For example: |
I'm confused about both parts of your post. Can you further explain how devise does this? One of the reasons to use database based things however is so that you can delete them server-side and disable the clients ability to activate There is no |
My bad, sorry. What I mean is "login function". Authboss "remember me" feature is something different from what I imagine.
What do you think about this, @aarondl? Can we call it "shallow remember me"? |
Something like: /auth/auth.go: // LoginPost attempts to validate the credentials passed in
// to log in a user.
func (a *Auth) LoginPost(w http.ResponseWriter, r *http.Request) error {
logger := a.RequestLogger(r)
validatable, err := a.Authboss.Core.BodyReader.Read(PageLogin, r)
if err != nil {
return err
}
if r.Form.Get("remember_me") == "on" {
fmt.Println("Yes, shallow remember me please!")
a.Config.Storage.SessionState.Store.Options.MaxAge = 30 * 60 *60 *24 // this obviously doesn't work as it is now
}
... |
This works, but: if r.Form.Get("remember_me") == "on" {
fmt.Println("Yes, shallow remember me please!")
oldCookie, _ := r.Cookie("MyCookieName")
newCookie := oldCookie
newCookie.MaxAge = 30 * 60 * 60 * 24
// newCookie.Domain = "" // path is every time "auth", why?
// newCookie.Path = "" // also with this path is every time "auth", why?
http.SetCookie(w, newCookie)
} but there is a problem: |
I fixed it using I cannot use this code in my |
I can use this, but: r.Group(func(r chi.Router) {
r.Use(authboss.ModuleListMiddleware(ab))
r.Use(checkShallowRememberMe)
r.Mount(AUTH_URL, http.StripPrefix(AUTH_URL, ab.Config.Core.Router))
})
func checkShallowRememberMe(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
utility.CheckErr(err)
ctx := r.Context()
if r.Form.Get("remember_me") == "on" {
oldSessionState := ctx.Value(authboss.CTXKeySessionState).(*abclientstate.SessionState)
oldSessionState.Options.MaxAge = 30*60*60*24*1000 // this doesn't work because Options is not in SessionState
ctx = context.WithValue(ctx, authboss.CTXKeySessionState, oldSessionState)
}
next.ServeHTTP(w, r.WithContext(ctx))
}
return http.HandlerFunc(fn)
} I still don't know how to find |
In order to control max age - you have to implement an Also - there is a checkbox in Authboss for remember me as well. The only difference is it uses the database and tokens. Having MaxAge = 0 is also an oddity because it means a user (or an attacker) can indefinitely stay logged in. With sites that have aggressive |
Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (#210).
It would be amazing to use "Remember me" feature not with DB token queries, just using the cookie
MaxAge > 0
if checkbox checked (like Rails devise gem does).Is there a way to do:
Maybe I'm wrong about this because maybe I did not understand how authboss remember_me module works. In that case I will create a wiki page to explain this to newbies like me.
The text was updated successfully, but these errors were encountered: