@amplication/plugin-auth-basic
Advanced tools
Comparing version 1.4.3 to 1.4.4
{ | ||
"name": "@amplication/plugin-auth-basic", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "set basic auth for Amplication build", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -15,1 +15,4 @@ /** | ||
"Authentication entity does not exist. Have you configured the authentication entity in the Resource Settings?"; | ||
export const AUTH_ENTITY_FIELD_USERNAME = "username"; | ||
export const AUTH_ENTITY_FIELD_PASSWORD = "password"; |
@@ -7,2 +7,3 @@ import { | ||
CreateServerAuthParams, | ||
CreateServerParams, | ||
DsgContext, | ||
@@ -16,6 +17,20 @@ EntityField, | ||
import { createAuthModule, createBasicStrategyBase } from "./core"; | ||
import { addIdentifierToConstructorSuperCall, addImports, addInjectableDependency, awaitExpression, getClassDeclarationById, importNames, interpolate, logicalExpression, memberExpression } from "./util/ast"; | ||
import { | ||
addIdentifierToConstructorSuperCall, | ||
addImports, | ||
addInjectableDependency, | ||
awaitExpression, | ||
getClassDeclarationById, | ||
importNames, | ||
interpolate, | ||
logicalExpression, | ||
memberExpression, | ||
} from "./util/ast"; | ||
import { builders, namedTypes } from "ast-types"; | ||
import { relativeImportPath } from "./util/module"; | ||
import { isPasswordField } from "./util/field"; | ||
import { | ||
AUTH_ENTITY_FIELD_PASSWORD, | ||
AUTH_ENTITY_FIELD_USERNAME, | ||
} from "./constants"; | ||
@@ -35,2 +50,5 @@ const ARGS_ID = builders.identifier("args"); | ||
return { | ||
CreateServer: { | ||
before: this.beforeCreateServer, | ||
}, | ||
CreateAdminUI: { | ||
@@ -52,2 +70,29 @@ before: this.beforeCreateAdminModules, | ||
beforeCreateServer(context: DsgContext, eventParams: CreateServerParams) { | ||
const authEntity = context.entities?.find( | ||
(x) => x.name === context.resourceInfo?.settings.authEntityName | ||
); | ||
if (!authEntity) { | ||
throw new Error(`Authentication entity does not exist`); | ||
} | ||
const requiredFields = [ | ||
AUTH_ENTITY_FIELD_USERNAME, | ||
AUTH_ENTITY_FIELD_PASSWORD, | ||
]; | ||
requiredFields.forEach((requiredField) => { | ||
const field = authEntity.fields.find( | ||
(field) => field.name === requiredField | ||
); | ||
if (!field) { | ||
throw new Error( | ||
`Authentication entity must have a field named ${requiredField}` | ||
); | ||
} | ||
}); | ||
return eventParams; | ||
} | ||
beforeCreateAdminModules( | ||
@@ -95,3 +140,2 @@ context: DsgContext, | ||
beforeCreateEntityService( | ||
@@ -98,0 +142,0 @@ context: DsgContext, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3108057
38795