findPathToAuthUsers() — supabase Function Reference
Architecture documentation for the findPathToAuthUsers() function in Policies.utils.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD f79e5138_9a55_c32e_e916_b04b77d8deb4["findPathToAuthUsers()"] 410a28a1_15c2_42bc_2aea_d86ef79842fa["generateProgrammaticPoliciesForTable()"] 410a28a1_15c2_42bc_2aea_d86ef79842fa -->|calls| f79e5138_9a55_c32e_e916_b04b77d8deb4 ecdff9bf_ef72_96b6_1353_50970d8742c5["getRelationshipsForTable()"] f79e5138_9a55_c32e_e916_b04b77d8deb4 -->|calls| ecdff9bf_ef72_96b6_1353_50970d8742c5 style f79e5138_9a55_c32e_e916_b04b77d8deb4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/Auth/Policies/Policies.utils.ts lines 214–270
const findPathToAuthUsers = (
startTable: { schema: string; name: string },
allForeignKeyConstraints: ForeignKeyConstraint[],
maxDepth = 3
): Relationship[] | null => {
const startRelationships = getRelationshipsForTable({
schema: startTable.schema,
table: startTable.name,
fkConstraints: allForeignKeyConstraints,
})
const queue: { table: { schema: string; name: string }; path: Relationship[] }[] = [
{ table: startTable, path: [] },
]
const visited = new Set<string>()
visited.add(`${startTable.schema}.${startTable.name}`)
while (queue.length > 0) {
const queueItem = queue.shift()
if (!queueItem) continue
const { table, path } = queueItem
if (path.length >= maxDepth) continue
const relationships =
path.length === 0
? startRelationships
: getRelationshipsForTable({
schema: table.schema,
table: table.name,
fkConstraints: allForeignKeyConstraints,
})
for (const rel of relationships) {
// Found path to auth.users
if (
rel.target_table_schema === 'auth' &&
rel.target_table_name === 'users' &&
rel.target_column_name === 'id'
) {
return [...path, rel]
}
const targetId = `${rel.target_table_schema}.${rel.target_table_name}`
if (visited.has(targetId)) continue
// Add target table to queue for further exploration
queue.push({
table: { schema: rel.target_table_schema, name: rel.target_table_name },
path: [...path, rel],
})
visited.add(targetId)
}
}
return null
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does findPathToAuthUsers() do?
findPathToAuthUsers() is a function in the supabase codebase.
What does findPathToAuthUsers() call?
findPathToAuthUsers() calls 1 function(s): getRelationshipsForTable.
What calls findPathToAuthUsers()?
findPathToAuthUsers() is called by 1 function(s): generateProgrammaticPoliciesForTable.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free