mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
fix: add https status to activity log (#6978)
* fix: add https status to activity log * create prerelease * create RC * pass info from gateway to grpc server * fix: update releaserc to create RC version * cleanup --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/activity"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/errors"
|
||||
@@ -14,17 +15,13 @@ import (
|
||||
|
||||
func ActivityInterceptor() grpc.UnaryServerInterceptor {
|
||||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
ctx = activityInfoFromGateway(ctx).SetMethod(info.FullMethod).IntoContext(ctx)
|
||||
resp, err := handler(ctx, req)
|
||||
if isResourceAPI(info.FullMethod) {
|
||||
code, _, _, _ := errors.ExtractCaosError(err)
|
||||
ctx = ainfo.ActivityInfoFromContext(ctx).SetGRPCStatus(code).IntoContext(ctx)
|
||||
activity.TriggerGRPCWithContext(ctx, activity.ResourceAPI)
|
||||
}
|
||||
if strings.HasPrefix(info.FullMethod, "/zitadel.session.v1.SessionService/") {
|
||||
code, _, _, _ := errors.ExtractCaosError(err)
|
||||
ctx = ainfo.ActivityInfoFromContext(ctx).SetGRPCStatus(code).IntoContext(ctx)
|
||||
activity.TriggerGRPCWithContext(ctx, activity.SessionAPI)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
@@ -42,3 +39,20 @@ func isResourceAPI(method string) bool {
|
||||
return strings.HasPrefix(method, prefix)
|
||||
})
|
||||
}
|
||||
|
||||
func activityInfoFromGateway(ctx context.Context) *ainfo.ActivityInfo {
|
||||
info := ainfo.ActivityInfoFromContext(ctx)
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return info
|
||||
}
|
||||
path := md.Get(activity.PathKey)
|
||||
if len(path) != 1 {
|
||||
return info
|
||||
}
|
||||
requestMethod := md.Get(activity.RequestMethodKey)
|
||||
if len(requestMethod) != 1 {
|
||||
return info
|
||||
}
|
||||
return info.SetPath(path[0]).SetRequestMethod(requestMethod[0])
|
||||
}
|
||||
|
Reference in New Issue
Block a user