-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication failed on aggregation with subdocuments #92
Comments
Same here import { Document, model, Schema } from "mongoose";
import encrypt from "mongoose-encryption";
import mongooseHidden from "mongoose-hidden";
`
export interface ISettings {
userId: string;
mapbox: {
user: string;
publicToken: string;
privateToken: string;
};
}
export type SettingsModel = ISettings & Document;
export const SettingsSchema = new Schema(
{
userId: { type: Schema.Types.ObjectId, ref: "User", required: true },
mapbox: {
user: String,
publicToken: String,
privateToken: String,
},
},
{
timestamps: true,
},
);
SettingsSchema.set("toJSON", {
virtuals: true,
});
SettingsSchema.plugin(encrypt, {
secret: "dupa",
encryptedFields: ["mapbox.privateToken"],
});
SettingsSchema.plugin(mongooseHidden({ hidden: { __t: true } }));
export const Settings = model<SettingsModel>("Settings", SettingsSchema); Then simple mongoose.find gives me "Authentication failed". I trakced that function authenticateSync gives me error because var authentic = bufferEqual(basicAC, expectedHMAC); // Here bufferEqual returns false
if (!authentic){
throw new Error('Authentication failed');
} |
@karenpommeroy I wonder if this is related to the |
For the original issue cited, aggregations in general aren't a tested aspect of this package. In general, I'd expect they might work if the fields involved aren't encrypted. However, in this particular case, the entire |
Hi,
I'm trying to use aggregate on initial access to a document, I have encrypted the subdocument. Error: UnhandledPromiseRejectionWarning: Error: Authentication failed: Only some authenticated fields were selected by the query. Either all or none of the authenticated fields (quotes,_ct,_ac) should be selected for proper authentication.
My Code:
The text was updated successfully, but these errors were encountered: