mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
remove pointer on ctxData
This commit is contained in:
parent
501d453822
commit
e5e39b3a6a
@ -2,7 +2,6 @@ package auth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/caos/logging"
|
"github.com/caos/logging"
|
||||||
)
|
)
|
||||||
@ -43,24 +42,15 @@ func VerifyTokenAndWriteCtxData(ctx context.Context, token, orgID string, t Toke
|
|||||||
projectID, err := t.GetProjectIDByClientID(ctx, clientID)
|
projectID, err := t.GetProjectIDByClientID(ctx, clientID)
|
||||||
logging.LogWithFields("AUTH-GfAoV", "clientID", clientID).OnError(err).Warn("could not read projectid by clientid")
|
logging.LogWithFields("AUTH-GfAoV", "clientID", clientID).OnError(err).Warn("could not read projectid by clientid")
|
||||||
|
|
||||||
return context.WithValue(ctx, CtxKeyData{}, &CtxData{UserID: userID, OrgID: orgID, ProjectID: projectID, AgentID: agentID}), nil
|
return context.WithValue(ctx, CtxKeyData{}, CtxData{UserID: userID, OrgID: orgID, ProjectID: projectID, AgentID: agentID}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCtxData(ctx context.Context) CtxData {
|
func GetCtxData(ctx context.Context) CtxData {
|
||||||
if data := ctx.Value(CtxKeyData{}); data != nil {
|
ctxData, _ := ctx.Value(CtxKeyData{}).(CtxData)
|
||||||
ctxData, ok := data.(*CtxData)
|
return ctxData
|
||||||
if ok {
|
|
||||||
return *ctxData
|
|
||||||
}
|
|
||||||
time.Now()
|
|
||||||
}
|
|
||||||
return CtxData{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPermissionsFromCtx(ctx context.Context) []string {
|
func GetPermissionsFromCtx(ctx context.Context) []string {
|
||||||
if data := ctx.Value(CtxKeyPermissions{}); data != nil {
|
ctxPermission, _ := ctx.Value(CtxKeyPermissions{}).([]string)
|
||||||
ctxPermission, _ := data.([]string)
|
|
||||||
return ctxPermission
|
return ctxPermission
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func getTestCtx(userID, orgID string) context.Context {
|
func getTestCtx(userID, orgID string) context.Context {
|
||||||
return context.WithValue(context.Background(), CtxKeyData{}, &CtxData{UserID: userID, OrgID: orgID})
|
return context.WithValue(context.Background(), CtxKeyData{}, CtxData{UserID: userID, OrgID: orgID})
|
||||||
}
|
}
|
||||||
|
|
||||||
type testVerifier struct {
|
type testVerifier struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user