47ng / 47ng/prisma-field-encryption

Fields that are selected through include are returned as cyphertext

Aperta
#92 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
306
Fork
40
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

When doing a query which includes encrypted fields, rather than selecting them directly, the field will return encrypted.
Example of my prisma schema:

```
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
}

generator fieldEncryptionMigrations {
provider = "prisma-field-encryption"
output = "./migrations"

// Optionally opt-in to concurrent model migration.
// Since this can cause timeouts and performance issues,
// it's off by default, and models are updated sequentially.
concurrently = true
}

datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}

enum Role {
USER
ADMIN
}

model User {
id String @id @default(cuid()) @map("_id")
accountId String @unique
email String /// @encrypted?mode=strict
role Role @default(USER)
subscriptions Subscription[] @relation("subscriptions")
createdSubscriptions Subscription[] @relation("createdSubscriptions")
}

model Subscription {
id String @id @default(cuid()) @map("_id")
name String
paymentUrl String
expiresOn DateTime
customerId String
customer User @relation("subscriptions", fields: [customerId], references: [id])
adminId String
admin User @relation("createdSubscriptions", fields: [adminId], references: [id])
}

```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

The issue describes encrypted fields being returned as ciphertext when selected via `include` in a query. Start by examining the middleware code that handles field encryption/decryption, likely in the main plugin or migration generator. Look for where `include` relations are processed versus direct field selection. Check the test suite for existing tests on relation queries to understand the expected behavior. Verify the fix by writing a test that reproduces the issue with a model that has encrypted fields and a relation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
mongodb, typescript
Ambito
backend-api-design, databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.