Add validation to plugins uploaded using file upload and allow component uploads via non-file sources in cloud
This commit is contained in:
parent
a866874b4b
commit
64ee1677e6
|
@ -53,10 +53,6 @@ export async function upload(ctx: any) {
|
||||||
export async function create(ctx: any) {
|
export async function create(ctx: any) {
|
||||||
const { source, url, headers, githubToken } = ctx.request.body
|
const { source, url, headers, githubToken } = ctx.request.body
|
||||||
|
|
||||||
if (!env.SELF_HOSTED) {
|
|
||||||
ctx.throw(400, "Plugins not supported outside of self-host.")
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let metadata
|
let metadata
|
||||||
let directory
|
let directory
|
||||||
|
@ -87,6 +83,13 @@ export async function create(ctx: any) {
|
||||||
|
|
||||||
validate(metadata?.schema)
|
validate(metadata?.schema)
|
||||||
|
|
||||||
|
// Only allow components in cloud
|
||||||
|
if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {
|
||||||
|
throw new Error(
|
||||||
|
"Only component plugins are supported outside of self-host"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const doc = await storePlugin(metadata, directory, source)
|
const doc = await storePlugin(metadata, directory, source)
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
|
@ -198,6 +201,7 @@ export async function storePlugin(
|
||||||
|
|
||||||
export async function processPlugin(plugin: FileType, source?: string) {
|
export async function processPlugin(plugin: FileType, source?: string) {
|
||||||
const { metadata, directory } = await fileUpload(plugin)
|
const { metadata, directory } = await fileUpload(plugin)
|
||||||
|
validate(metadata?.schema)
|
||||||
|
|
||||||
// Only allow components in cloud
|
// Only allow components in cloud
|
||||||
if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {
|
if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {
|
||||||
|
|
Loading…
Reference in New Issue