File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
app/api/settings/allowed-integrations Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server'
2+ import { getSession } from '@/lib/auth'
23import { getAllowedIntegrationsFromEnv } from '@/lib/core/config/feature-flags'
34
45export async function GET ( ) {
6+ const session = await getSession ( )
7+ if ( ! session ?. user ?. id ) {
8+ return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } )
9+ }
10+
511 return NextResponse . json ( {
612 allowedIntegrations : getAllowedIntegrationsFromEnv ( ) ,
713 } )
Original file line number Diff line number Diff line change @@ -27,8 +27,12 @@ export class ProviderNotAllowedError extends Error {
2727}
2828
2929export class IntegrationNotAllowedError extends Error {
30- constructor ( blockType : string ) {
31- super ( `Integration "${ blockType } " is not allowed based on your permission group settings` )
30+ constructor ( blockType : string , reason ?: string ) {
31+ super (
32+ reason
33+ ? `Integration "${ blockType } " is not allowed: ${ reason } `
34+ : `Integration "${ blockType } " is not allowed based on your permission group settings`
35+ )
3236 this . name = 'IntegrationNotAllowedError'
3337 }
3438}
@@ -159,7 +163,7 @@ export async function validateBlockType(
159163 const envAllowlist = getAllowedIntegrationsFromEnv ( )
160164 if ( envAllowlist !== null && ! envAllowlist . includes ( blockType ) ) {
161165 logger . warn ( 'Integration blocked by env allowlist' , { blockType } )
162- throw new IntegrationNotAllowedError ( blockType )
166+ throw new IntegrationNotAllowedError ( blockType , 'blocked by server ALLOWED_INTEGRATIONS policy' )
163167 }
164168
165169 if ( ! userId ) {
Original file line number Diff line number Diff line change @@ -53,8 +53,13 @@ export function usePermissionConfig(): PermissionConfigResult {
5353 const { data : organizationsData } = useOrganizations ( )
5454 const activeOrganization = organizationsData ?. activeOrganization
5555
56- const { data : permissionData , isLoading } = useUserPermissionConfig ( activeOrganization ?. id )
57- const { data : envAllowlistData } = useAllowedIntegrationsFromEnv ( )
56+ const { data : permissionData , isLoading : isPermissionLoading } = useUserPermissionConfig (
57+ activeOrganization ?. id
58+ )
59+ const { data : envAllowlistData , isLoading : isEnvAllowlistLoading } =
60+ useAllowedIntegrationsFromEnv ( )
61+
62+ const isLoading = isPermissionLoading || isEnvAllowlistLoading
5863
5964 const config = useMemo ( ( ) => {
6065 if ( accessControlDisabled ) {
You can’t perform that action at this time.
0 commit comments