mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 06:45:28 +00:00
Begin api-key functionality on backend
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { Schema, model, Types } from 'mongoose';
|
||||
import { ENV_DEV, ENV_TESTING, ENV_STAGING, ENV_PROD } from '../variables';
|
||||
|
||||
// TODO: add scopes
|
||||
|
||||
export interface IAPIKey {
|
||||
name: string;
|
||||
workspace: string;
|
||||
environment: string;
|
||||
expiresAt: Date;
|
||||
prefix: string;
|
||||
apiKeyHash: string;
|
||||
encryptedKey: string;
|
||||
iv: string;
|
||||
tag: string;
|
||||
}
|
||||
|
||||
const apiKeySchema = new Schema<IAPIKey>(
|
||||
{
|
||||
name: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
workspace: {
|
||||
type: String
|
||||
},
|
||||
environment: {
|
||||
type: String,
|
||||
enum: [ENV_DEV, ENV_TESTING, ENV_STAGING, ENV_PROD]
|
||||
},
|
||||
expiresAt: {
|
||||
type: Date
|
||||
},
|
||||
prefix: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
apiKeyHash: {
|
||||
type: String,
|
||||
unique: true,
|
||||
required: true
|
||||
},
|
||||
encryptedKey: {
|
||||
type: String,
|
||||
select: true
|
||||
},
|
||||
iv: {
|
||||
type: String,
|
||||
select: true
|
||||
},
|
||||
tag: {
|
||||
type: String,
|
||||
select: true
|
||||
}
|
||||
},
|
||||
{
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
const APIKey = model<IAPIKey>('APIKey', apiKeySchema);
|
||||
|
||||
export default APIKey;
|
||||
@@ -14,6 +14,7 @@ import Token, { IToken } from './token';
|
||||
import User, { IUser } from './user';
|
||||
import UserAction, { IUserAction } from './userAction';
|
||||
import Workspace, { IWorkspace } from './workspace';
|
||||
import APIKey, { IAPIKey } from './apiKey';
|
||||
|
||||
export {
|
||||
BackupPrivateKey,
|
||||
@@ -47,5 +48,7 @@ export {
|
||||
UserAction,
|
||||
IUserAction,
|
||||
Workspace,
|
||||
IWorkspace
|
||||
IWorkspace,
|
||||
APIKey,
|
||||
IAPIKey,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user