fix: replace all logs
This commit is contained in:
parent
d7bb10fd21
commit
d886d780b4
|
@ -59,9 +59,10 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
||||||
|
|
||||||
verificationToken, err := token.CreateVerificationToken(params.Email, constants.VerificationTypeForgotPassword, hostname, nonceHash, redirectURL)
|
verificationToken, err := token.CreateVerificationToken(params.Email, constants.VerificationTypeForgotPassword, hostname, nonceHash, redirectURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`error generating token`, err)
|
log.Debug("Failed to create verification token", err)
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
db.Provider.AddVerificationRequest(models.VerificationRequest{
|
_, err = db.Provider.AddVerificationRequest(models.VerificationRequest{
|
||||||
Token: verificationToken,
|
Token: verificationToken,
|
||||||
Identifier: constants.VerificationTypeForgotPassword,
|
Identifier: constants.VerificationTypeForgotPassword,
|
||||||
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
|
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
|
||||||
|
@ -69,6 +70,10 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
||||||
Nonce: nonceHash,
|
Nonce: nonceHash,
|
||||||
RedirectURI: redirectURL,
|
RedirectURI: redirectURL,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("Failed to add verification request", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
// exec it as go routin so that we can reduce the api latency
|
// exec it as go routin so that we can reduce the api latency
|
||||||
go email.SendForgotPasswordMail(params.Email, verificationToken, hostname)
|
go email.SendForgotPasswordMail(params.Email, verificationToken, hostname)
|
||||||
|
|
|
@ -2,8 +2,9 @@ package sessionstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RedisStore struct {
|
type RedisStore struct {
|
||||||
|
@ -15,7 +16,7 @@ type RedisStore struct {
|
||||||
func (c *RedisStore) ClearStore() {
|
func (c *RedisStore) ClearStore() {
|
||||||
err := c.store.Del(c.ctx, "authorizer_*").Err()
|
err := c.store.Del(c.ctx, "authorizer_*").Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Error clearing redis store:", err)
|
log.Debug("Error clearing redis store:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ func (c *RedisStore) ClearStore() {
|
||||||
func (c *RedisStore) GetUserSessions(userID string) map[string]string {
|
func (c *RedisStore) GetUserSessions(userID string) map[string]string {
|
||||||
data, err := c.store.HGetAll(c.ctx, "*").Result()
|
data, err := c.store.HGetAll(c.ctx, "*").Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error getting token from redis store:", err)
|
log.Debug("error getting token from redis store:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := map[string]string{}
|
res := map[string]string{}
|
||||||
|
@ -44,7 +45,7 @@ func (c *RedisStore) DeleteAllUserSession(userId string) {
|
||||||
if k == "token" {
|
if k == "token" {
|
||||||
err := c.store.Del(c.ctx, v)
|
err := c.store.Del(c.ctx, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error deleting redis token:", err)
|
log.Debug("Error deleting redis token:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +55,7 @@ func (c *RedisStore) DeleteAllUserSession(userId string) {
|
||||||
func (c *RedisStore) SetState(key, value string) {
|
func (c *RedisStore) SetState(key, value string) {
|
||||||
err := c.store.Set(c.ctx, "authorizer_"+key, value, 0).Err()
|
err := c.store.Set(c.ctx, "authorizer_"+key, value, 0).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Error saving redis token:", err)
|
log.Debug("Error saving redis token:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ func (c *RedisStore) GetState(key string) string {
|
||||||
state := ""
|
state := ""
|
||||||
state, err := c.store.Get(c.ctx, "authorizer_"+key).Result()
|
state, err := c.store.Get(c.ctx, "authorizer_"+key).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error getting token from redis store:", err)
|
log.Debug("error getting token from redis store:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|
|
@ -2,9 +2,10 @@ package sessionstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/authorizerdev/authorizer/server/constants"
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
"github.com/authorizerdev/authorizer/server/envstore"
|
"github.com/authorizerdev/authorizer/server/envstore"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
|
@ -89,7 +90,7 @@ func RemoveState(key string) {
|
||||||
// InitializeSessionStore initializes the SessionStoreObj based on environment variables
|
// InitializeSessionStore initializes the SessionStoreObj based on environment variables
|
||||||
func InitSession() error {
|
func InitSession() error {
|
||||||
if envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyRedisURL) != "" {
|
if envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyRedisURL) != "" {
|
||||||
log.Println("using redis store to save sessions")
|
log.Info("using redis store to save sessions")
|
||||||
|
|
||||||
redisURL := envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyRedisURL)
|
redisURL := envstore.EnvStoreObj.GetStringStoreEnvVariable(constants.EnvKeyRedisURL)
|
||||||
redisURLHostPortsList := strings.Split(redisURL, ",")
|
redisURLHostPortsList := strings.Split(redisURL, ",")
|
||||||
|
|
|
@ -3,10 +3,11 @@ package token
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/golang-jwt/jwt"
|
"github.com/golang-jwt/jwt"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -330,14 +331,13 @@ func CreateIDToken(user models.User, roles []string, hostname, nonce string) (st
|
||||||
`, string(userBytes), string(claimBytes), accessTokenScript))
|
`, string(userBytes), string(claimBytes), accessTokenScript))
|
||||||
|
|
||||||
val, err := vm.Get("functionRes")
|
val, err := vm.Get("functionRes")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error getting custom access token script:", err)
|
log.Debug("error getting custom access token script:", err)
|
||||||
} else {
|
} else {
|
||||||
extraPayload := make(map[string]interface{})
|
extraPayload := make(map[string]interface{})
|
||||||
err = json.Unmarshal([]byte(fmt.Sprintf("%s", val)), &extraPayload)
|
err = json.Unmarshal([]byte(fmt.Sprintf("%s", val)), &extraPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error converting accessTokenScript response to map:", err)
|
log.Debug("error converting accessTokenScript response to map:", err)
|
||||||
} else {
|
} else {
|
||||||
for k, v := range extraPayload {
|
for k, v := range extraPayload {
|
||||||
customClaims[k] = v
|
customClaims[k] = v
|
||||||
|
|
Loading…
Reference in New Issue
Block a user