-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete v1 secret versioning and project secret snapshots
- Loading branch information
1 parent
c8633bf
commit dca3bd4
Showing
5 changed files
with
332 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { Schema, model, Types } from 'mongoose'; | ||
import { | ||
SECRET_SHARED, | ||
SECRET_PERSONAL, | ||
ENV_DEV, | ||
ENV_TESTING, | ||
ENV_STAGING, | ||
ENV_PROD | ||
} from '../variables'; | ||
|
||
export interface ISecretSnapshot { | ||
workspace: Types.ObjectId; | ||
version: number; | ||
secrets: { | ||
version: number; | ||
workspace: Types.ObjectId; | ||
type: string; | ||
user: Types.ObjectId; | ||
environment: string; | ||
secretKeyCiphertext: string; | ||
secretKeyIV: string; | ||
secretKeyTag: string; | ||
secretKeyHash: string; | ||
secretValueCiphertext: string; | ||
secretValueIV: string; | ||
secretValueTag: string; | ||
secretValueHash: string; | ||
}[] | ||
} | ||
|
||
const secretSnapshotSchema = new Schema<ISecretSnapshot>( | ||
{ | ||
workspace: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Workspace', | ||
required: true | ||
}, | ||
version: { | ||
type: Number, | ||
required: true | ||
}, | ||
secrets: [{ | ||
version: { | ||
type: Number, | ||
default: 1, | ||
required: true | ||
}, | ||
workspace: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Workspace', | ||
required: true | ||
}, | ||
type: { | ||
type: String, | ||
enum: [SECRET_SHARED, SECRET_PERSONAL], | ||
required: true | ||
}, | ||
user: { | ||
// user associated with the personal secret | ||
type: Schema.Types.ObjectId, | ||
ref: 'User' | ||
}, | ||
environment: { | ||
type: String, | ||
enum: [ENV_DEV, ENV_TESTING, ENV_STAGING, ENV_PROD], | ||
required: true | ||
}, | ||
secretKeyCiphertext: { | ||
type: String, | ||
required: true | ||
}, | ||
secretKeyIV: { | ||
type: String, // symmetric | ||
required: true | ||
}, | ||
secretKeyTag: { | ||
type: String, // symmetric | ||
required: true | ||
}, | ||
secretKeyHash: { | ||
type: String, | ||
required: true | ||
}, | ||
secretValueCiphertext: { | ||
type: String, | ||
required: true | ||
}, | ||
secretValueIV: { | ||
type: String, // symmetric | ||
required: true | ||
}, | ||
secretValueTag: { | ||
type: String, // symmetric | ||
required: true | ||
}, | ||
secretValueHash: { | ||
type: String, | ||
required: true | ||
} | ||
}] | ||
}, | ||
{ | ||
timestamps: true | ||
} | ||
); | ||
|
||
const SecretSnapshot = model<ISecretSnapshot>('SecretSnapshot', secretSnapshotSchema); | ||
|
||
export default SecretSnapshot; |
Oops, something went wrong.