func SessionFromRequest(ctx *context.Context, r *http.Request) (*store.Session, error) { sid, err := SessionIdFromRequest(ctx, r) if err != nil { return nil, err } return store.FindSession(ctx, sid) }
func SessionFromToken(ctx *context.Context, token string) (*store.Session, error) { buf, err := base62.DecodeString(token) if err != nil { return nil, err } key, _, err := secure.Decrypt(buf, ctx.Cfg.AesKey, ctx.Cfg.HmacKey) if err != nil { return nil, err } // TODO(knorton): age must be checked. return store.FindSession(ctx, key) }