Repository: inspektor-dev/inspektor (language: rust)

Issue:
Add a optional pass through mechanism if query failed. 
**Is your feature request related to a problem? Please describe.**
if we not able to parse any of the query instead of failing, dataplane should be able to pass through the query 

**Describe the solution you'd like**
This could solve the unsupported postgres operators. we can add the support by taking the control plane reports. 


Discussion / hints:

Fix patch:
diff --git a/controlplane/apiproto/api.pb.go b/controlplane/apiproto/api.pb.go
index 5e5f444..ed78bad 100644
--- a/controlplane/apiproto/api.pb.go
+++ b/controlplane/apiproto/api.pb.go
@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.25.0-devel
-// 	protoc        v3.14.0
+// 	protoc-gen-go v1.27.1
+// 	protoc        v3.6.1
 // source: api.proto
 
 package apiproto
@@ -118,8 +118,9 @@ type AuthResponse struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Groups    []string `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"`
-	ExpiresAt int64    `protobuf:"varint,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
+	Groups      []string `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"`
+	ExpiresAt   int64    `protobuf:"varint,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
+	Passthrough bool     `protobuf:"varint,3,opt,name=passthrough,proto3" json:"passthrough,omitempty"`
 }
 
 func (x *AuthResponse) Reset() {
@@ -168,6 +169,13 @@ func (x *AuthResponse) GetExpiresAt() int64 {
 	return 0
 }
 
+func (x *AuthResponse) GetPassthrough() bool {
+	if x != nil {
+		return x.Passthrough
+	}
+	return false
+}
+
 type DataSourceResponse struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -381,45 +389,47 @@ var file_api_proto_rawDesc = []byte{
 	0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x75,
 	0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
 	0x75, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74,
-	0x79, 0x22, 0x45, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
+	0x79, 0x22, 0x67, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
 	0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
 	0x09, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x78, 0x70,
 	0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65,
-	0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x22, 0x3e, 0x0a, 0x12, 0x44, 0x61, 0x74, 0x61,
-	0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28,
-	0x0a, 0x10, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6e, 0x61,
-	0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x61, 0x74, 0x61, 0x53, 0x6f,
-	0x75, 0x72, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x49, 0x6e, 0x73, 0x70,
-	0x65, 0x6b, 0x74, 0x6f, 0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x24, 0x0a, 0x0e, 0x77,
-	0x61, 0x73, 0x6d, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x0c, 0x52, 0x0c, 0x77, 0x61, 0x73, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x43, 0x6f, 0x64,
-	0x65, 0x22, 0x4f, 0x0a, 0x0e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x18, 0x01,
-	0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69,
-	0x63, 0x52, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x72,
-	0x6f, 0x75, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75,
-	0x70, 0x73, 0x22, 0x56, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x27, 0x0a, 0x0f,
-	0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18,
-	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
-	0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74,
-	0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72,
-	0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0xd4, 0x01, 0x0a, 0x09, 0x49,
-	0x6e, 0x73, 0x70, 0x65, 0x6b, 0x74, 0x6f, 0x72, 0x12, 0x2d, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68,
-	0x12, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65,
-	0x73, 0x74, 0x1a, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73,
-	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2e, 0x0a, 0x06, 0x50, 0x6f, 0x6c, 0x69, 0x63,
-	0x79, 0x12, 0x0a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e,
-	0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x6b, 0x74, 0x6f, 0x72, 0x50, 0x6f, 0x6c,
-	0x69, 0x63, 0x79, 0x22, 0x00, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x44, 0x61,
-	0x74, 0x61, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x0a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45,
-	0x6d, 0x70, 0x74, 0x79, 0x1a, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x53,
-	0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
-	0x30, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x13,
-	0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22,
-	0x00, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e,
-	0x65, 0x2f, 0x61, 0x70, 0x69, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
-	0x6f, 0x33,
+	0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x61, 0x73, 0x73,
+	0x74, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x70,
+	0x61, 0x73, 0x73, 0x74, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x22, 0x3e, 0x0a, 0x12, 0x44, 0x61,
+	0x74, 0x61, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
+	0x12, 0x28, 0x0a, 0x10, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f,
+	0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x61, 0x74, 0x61,
+	0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x49, 0x6e,
+	0x73, 0x70, 0x65, 0x6b, 0x74, 0x6f, 0x72, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x24, 0x0a,
+	0x0e, 0x77, 0x61, 0x73, 0x6d, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x77, 0x61, 0x73, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x43,
+	0x6f, 0x64, 0x65, 0x22, 0x4f, 0x0a, 0x0e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65,
+	0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
+	0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x74,
+	0x72, 0x69, 0x63, 0x52, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x16, 0x0a, 0x06,
+	0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x67, 0x72,
+	0x6f, 0x75, 0x70, 0x73, 0x22, 0x56, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x27,
+	0x0a, 0x0f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d,
+	0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,
+	0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x65,
+	0x72, 0x74, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c,
+	0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0xd4, 0x01, 0x0a,
+	0x09, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x6b, 0x74, 0x6f, 0x72, 0x12, 0x2d, 0x0a, 0x04, 0x41, 0x75,
+	0x74, 0x68, 0x12, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71,
+	0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52,
+	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2e, 0x0a, 0x06, 0x50, 0x6f, 0x6c,
+	0x69, 0x63, 0x79, 0x12, 0x0a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a,
+	0x14, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x6b, 0x74, 0x6f, 0x72, 0x50,
+	0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x00, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x0d, 0x47, 0x65, 0x74,
+	0x44, 0x61, 0x74, 0x61, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x0a, 0x2e, 0x61, 0x70, 0x69,
+	0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74,
+	0x61, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
+	0x00, 0x12, 0x30, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
+	0x12, 0x13, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65,
+	0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74,
+	0x79, 0x22, 0x00, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c,
+	0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
diff --git a/controlplane/handlers/session.go b/controlplane/handlers/session.go
index 15f2cf9..af20f14 100644
--- a/controlplane/handlers/session.go
+++ b/controlplane/handlers/session.go
@@ -80,7 +80,7 @@ func (h *Handlers) CreateSession() InspectorHandler {
 			utils.WriteErrorMsg("unauthorized access", http.StatusBadRequest, ctx.Rw)
 			return
 		}
-		err = h.Store.CreateSessionForUser(ctx.Claim.ObjectID, req.DatasourceID)
+		err = h.Store.CreateSessionForUser(ctx.Claim.ObjectID, req.DatasourceID, req.Passthrough)
 		if err != nil {
 			handleErr(err, ctx)
 			return
diff --git a/controlplane/models/session.go b/controlplane/models/session.go
index 5cc70c2..b96ae17 100644
--- a/controlplane/models/session.go
+++ b/controlplane/models/session.go
@@ -25,6 +25,7 @@ type SessionMeta struct {
 	ExpiresAt        int64           `json:"expiresAt"`
 	Context          json.RawMessage `json:"context"`
 	TempCreatedBy    string          `json:"tempCreatedBy"`
+	Passthrough      bool            `json:"passthrough"`
 }
 
 func (s *Session) UnmarshalMeta() {
diff --git a/controlplane/rpcserver/server.go b/controlplane/rpcserver/server.go
index 3c792a7..067a750 100644
--- a/controlplane/rpcserver/server.go
+++ b/controlplane/rpcserver/server.go
@@ -64,8 +64,9 @@ func (r *RpcServer) Auth(ctx context.Context, req *apiproto.AuthRequest) (*apipr
 		}
 	}
 	return &apiproto.AuthResponse{
-		Groups:    roles,
-		ExpiresAt: expiresAt,
+		Groups:      roles,
+		ExpiresAt:   expiresAt,
+		Passthrough: session.SessionMeta.Passthrough,
 	}, nil
 }
 
diff --git a/controlplane/store/store.go b/controlplane/store/store.go
index 601413a..a62a481 100644
--- a/controlplane/store/store.go
+++ b/controlplane/store/store.go
@@ -217,7 +217,7 @@ func (s *Store) GetSessionForAuth(objectID uint, username string, password strin
 	return session, err
 }
 
-func (s *Store) CreateSessionForUser(userID uint, datasourceID uint) error {
+func (s *Store) CreateSessionForUser(userID uint, datasourceID uint, passthrough bool) error {
 	return s.db.Transaction(func(tx *gorm.DB) error {
 		var count int64
 		err := tx.Model(&models.Session{}).Where("user_id = ? AND object_id = ?", userID, datasourceID).Count(&count).Error
@@ -236,6 +236,7 @@ func (s *Store) CreateSessionForUser(userID uint, datasourceID uint) error {
 				Type:             "postgres",
 				PostgresPassword: utils.GenerateSecureToken(7),
 				PostgresUsername: namegenerator.NewNameGenerator(time.Now().UnixNano()).Generate(),
+				Passthrough:      passthrough,
 			},
 		}
 		session.MarshalMeta()
diff --git a/controlplane/types/types.go b/controlplane/types/types.go
index e305fcf..bc29ba0 100644
--- a/controlplane/types/types.go
+++ b/controlplane/types/types.go
@@ -74,6 +74,7 @@ func (c *CreateDataSourceRequest) Validate() error {
 
 type CreateSessionRequest struct {
 	DatasourceID uint `json:"datasourceId"`
+	Passthrough  bool `json:"passthrough"`
 }
 
 type ConfigResponse struct {
diff --git a/proto/api.proto b/proto/api.proto
index 991e809..1d83b50 100644
--- a/proto/api.proto
+++ b/proto/api.proto
@@ -14,6 +14,7 @@ message Empty {
 message AuthResponse {
     repeated string groups = 1;
     int64 expires_at = 2;
+    bool passthrough = 3;
 }
 
 message DataSourceResponse {
diff --git a/src/apiproto/api.rs b/src/apiproto/api.rs
index cc455cd..a20574c 100644
--- a/src/apiproto/api.rs
+++ b/src/apiproto/api.rs
@@ -345,6 +345,7 @@ pub struct AuthResponse {
     // message fields
     pub groups: ::protobuf::RepeatedField<::std::string::String>,
     pub expires_at: i64,
+    pub passthrough: bool,
     // special fields
     pub unknown_fields: ::protobuf::UnknownFields,
     pub cached_size: ::protobuf::CachedSize,
@@ -400,6 +401,21 @@ impl AuthResponse {
     pub fn set_expires_at(&mut self, v: i64) {
         self.expires_at = v;
     }
+
+    // bool passthrough = 3;
+
+
+    pub fn get_passthrough(&self) -> bool {
+        self.passthrough
+    }
+    pub fn clear_passthrough(&mut self) {
+        self.passthrough = false;
+    }
+
+    // Param is passed by value, moved
+    pub fn set_passthrough(&mut self, v: bool) {
+        self.passthrough = v;
+    }
 }
 
 impl ::protobuf::Message for AuthResponse {
@@ -421,6 +437,13 @@ impl ::protobuf::Message for AuthResponse {
                     let tmp = is.read_int64()?;
                     self.expires_at = tmp;
                 },
+                3 => {
+                    if wire_type != ::protobuf::wire_format::WireTypeVarint {
+                        return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
+                    }
+                    let tmp = is.read_bool()?;
+                    self.passthrough = tmp;
+                },
                 _ => {
                     ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
                 },
@@ -439,6 +462,9 @@ impl ::protobuf::Message for AuthResponse {
         if self.expires_at != 0 {
             my_size += ::protobuf::rt::value_size(2, self.expires_at, ::protobuf::wire_format::WireTypeVarint);
         }
+        if self.passthrough != false {
+            my_size += 2;
+        }
         my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
         self.cached_size.set(my_size);
         my_size
@@ -451,6 +477,9 @@ impl ::protobuf::Message for AuthResponse {
         if self.expires_at != 0 {
             os.write_int64(2, self.expires_at)?;
         }
+        if self.passthrough != false {
+            os.write_bool(3, self.passthrough)?;
+        }
         os.write_unknown_fields(self.get_unknown_fields())?;
         ::std::result::Result::Ok(())
     }
@@ -499,6 +528,11 @@ impl ::protobuf::Message for AuthResponse {
                 |m: &AuthResponse| { &m.expires_at },
                 |m: &mut AuthResponse| { &mut m.expires_at },
             ));
+            fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
+                "passthrough",
+                |m: &AuthResponse| { &m.passthrough },
+                |m: &mut AuthResponse| { &mut m.passthrough },
+            ));
             ::protobuf::reflect::MessageDescriptor::new_pb_name::<AuthResponse>(
                 "AuthResponse",
                 fields,
@@ -517,6 +551,7 @@ impl ::protobuf::Clear for AuthResponse {
     fn clear(&mut self) {
         self.groups.clear();
         self.expires_at = 0;
+        self.passthrough = false;
         self.unknown_fields.clear();
     }
 }
@@ -1261,20 +1296,21 @@ impl ::protobuf::reflect::ProtobufValue for Metric {
 static file_descriptor_proto_data: &'static [u8] = b"\
     \n\tapi.proto\x12\x03api\"F\n\x0bAuthRequest\x12\x1a\n\x08password\x18\
     \x01\x20\x01(\tR\x08password\x12\x1b\n\tuser_name\x18\x02\x20\x01(\tR\
-    \x08userName\"\x07\n\x05Empty\"E\n\x0cAuthResponse\x12\x16\n\x06groups\
+    \x08userName\"\x07\n\x05Empty\"g\n\x0cAuthResponse\x12\x16\n\x06groups\
     \x18\x01\x20\x03(\tR\x06groups\x12\x1d\n\nexpires_at\x18\x02\x20\x01(\
-    \x03R\texpiresAt\">\n\x12DataSourceResponse\x12(\n\x10data_source_name\
-    \x18\x01\x20\x01(\tR\x0edataSourceName\"7\n\x0fInspektorPolicy\x12$\n\
-    \x0ewasm_byte_code\x18\x01\x20\x01(\x0cR\x0cwasmByteCode\"O\n\x0eMetrics\
-    Request\x12%\n\x07metrics\x18\x01\x20\x03(\x0b2\x0b.api.MetricR\x07metri\
-    cs\x12\x16\n\x06groups\x18\x02\x20\x03(\tR\x06groups\"V\n\x06Metric\x12'\
-    \n\x0fcollection_name\x18\x01\x20\x01(\tR\x0ecollectionName\x12#\n\rprop\
-    erty_name\x18\x02\x20\x03(\tR\x0cpropertyName2\xd4\x01\n\tInspektor\x12-\
-    \n\x04Auth\x12\x10.api.AuthRequest\x1a\x11.api.AuthResponse\"\0\x12.\n\
-    \x06Policy\x12\n.api.Empty\x1a\x14.api.InspektorPolicy\"\00\x01\x126\n\r\
-    GetDataSource\x12\n.api.Empty\x1a\x17.api.DataSourceResponse\"\0\x120\n\
-    \x0bSendMetrics\x12\x13.api.MetricsRequest\x1a\n.api.Empty\"\0B\x17Z\x15\
-    controlplane/apiprotob\x06proto3\
+    \x03R\texpiresAt\x12\x20\n\x0bpassthrough\x18\x03\x20\x01(\x08R\x0bpasst\
+    hrough\">\n\x12DataSourceResponse\x12(\n\x10data_source_name\x18\x01\x20\
+    \x01(\tR\x0edataSourceName\"7\n\x0fInspektorPolicy\x12$\n\x0ewasm_byte_c\
+    ode\x18\x01\x20\x01(\x0cR\x0cwasmByteCode\"O\n\x0eMetricsRequest\x12%\n\
+    \x07metrics\x18\x01\x20\x03(\x0b2\x0b.api.MetricR\x07metrics\x12\x16\n\
+    \x06groups\x18\x02\x20\x03(\tR\x06groups\"V\n\x06Metric\x12'\n\x0fcollec\
+    tion_name\x18\x01\x20\x01(\tR\x0ecollectionName\x12#\n\rproperty_name\
+    \x18\x02\x20\x03(\tR\x0cpropertyName2\xd4\x01\n\tInspektor\x12-\n\x04Aut\
+    h\x12\x10.api.AuthRequest\x1a\x11.api.AuthResponse\"\0\x12.\n\x06Policy\
+    \x12\n.api.Empty\x1a\x14.api.InspektorPolicy\"\00\x01\x126\n\rGetDataSou\
+    rce\x12\n.api.Empty\x1a\x17.api.DataSourceResponse\"\0\x120\n\x0bSendMet\
+    rics\x12\x13.api.MetricsRequest\x1a\n.api.Empty\"\0B\x17Z\x15controlplan\
+    e/apiprotob\x06proto3\
 ";
 
 static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
diff --git a/src/postgres_driver/driver.rs b/src/postgres_driver/driver.rs
index 92c1981..e09b163 100644
--- a/src/postgres_driver/driver.rs
+++ b/src/postgres_driver/driver.rs
@@ -1,6 +1,6 @@
 use std::collections::HashMap;
 
-use crate::apiproto::api::{AuthRequest, DataSourceResponse};
+use crate::apiproto::api::{AuthRequest, DataSourceResponse, AuthResponse};
 use crate::apiproto::api_grpc::*;
 use crate::config::PostgresConfig;
 use crate::policy_evaluator::evaluator::PolicyEvaluator;
@@ -104,7 +104,7 @@ impl PostgresDriver {
             match msg {
                 FrontendMessage::Startup { params, .. } => {
                     // let's verify the user name and
-                    let (groups, session_expires_at) =
+                    let auth_res =
                         match self.verfiy_client_params(&params, &mut client_conn).await {
                             Ok(result) => result,
                             Err(e) => {
@@ -121,6 +121,7 @@ impl PostgresDriver {
                         }
                     };
 
+                    let groups: Vec<String> = auth_res.get_groups().into();
                     let result = match evaluator.evaluate(
                         &self.datasource.data_source_name,
                         &"view".to_string(),
@@ -160,6 +161,7 @@ impl PostgresDriver {
                         self.datasource.data_source_name.clone(),
                         self.client.clone(),
                         self.token.clone(),
+                        auth_res.passthrough
                     )
                     .await
                     {
@@ -169,7 +171,7 @@ impl PostgresDriver {
                             return;
                         }
                     };
-                    handler.serve(session_expires_at).await.unwrap();
+                    handler.serve(auth_res.expires_at).await.unwrap();
                     return;
                 }
                 FrontendMessage::SslRequest => {
@@ -213,7 +215,7 @@ impl PostgresDriver {
         &self,
         params: &HashMap<String, String>,
         client_conn: &mut PostgresConn,
-    ) -> Result<(Vec<String>, i64), anyhow::Error> {
+    ) -> Result<AuthResponse, anyhow::Error> {
         let buf = BackendMessage::AuthenticationCleartextPassword.encode();
         client_conn.write_all(&buf).await.map_err(|e| {
             error!(
@@ -235,7 +237,7 @@ impl PostgresDriver {
         auth_req.password = password;
         auth_req.user_name = params.get("user").unwrap().clone();
         let res = self.client.auth_opt(&auth_req, self.get_call_opt())?;
-        Ok((res.get_groups().into(), res.expires_at))
+        Ok(res)
     }
 
     fn get_call_opt(&self) -> CallOption {
diff --git a/src/postgres_driver/protocol_handler.rs b/src/postgres_driver/protocol_handler.rs
index f92829b..827b211 100644
--- a/src/postgres_driver/protocol_handler.rs
+++ b/src/postgres_driver/protocol_handler.rs
@@ -64,6 +64,7 @@ pub struct ProtocolHandler {
     client: InspektorClient,
     pending_metrics: RepeatedField<Metric>,
     token: String,
+    passthrough: bool
 }
 
 #[derive(Default)]
@@ -328,6 +329,7 @@ impl ProtocolHandler {
         datasource_name: String,
         controlplane_client: InspektorClient,
         token: String,
+        passthrough: bool
     ) -> Result<ProtocolHandler, anyhow::Error> {
         debug!("intializing protocol handler");
         let mut target_conn = ProtocolHandler::connect_target(&config).await?;
@@ -445,6 +447,7 @@ impl ProtocolHandler {
                         client: controlplane_client,
                         pending_metrics: RepeatedField::default(),
                         token: token,
+                        passthrough: passthrough,
                     };
                     return Ok(handler);
                 }
@@ -644,6 +647,9 @@ impl ProtocolHandler {
                     "error while parsing user query error: {} query string: {}",
                     e, query
                 );
+                if self.passthrough {
+                    return Ok(())
+                }
                 return Err(ProtocolHandlerError::ErrParsingQuery);
             }
         };


Test patch: