Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

add auth constants

TzeYiing877f9b4aae5b
diff --git a/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/studio/components/interfaces/Settings/Logs/Logs.constants.ts
index a3bb609b3ce..b9ac1ceeae3 100644
--- a/studio/components/interfaces/Settings/Logs/Logs.constants.ts
+++ b/studio/components/interfaces/Settings/Logs/Logs.constants.ts
@@ -229,6 +229,9 @@ export const SQL_FILTER_TEMPLATES: any = {
'severity.info': `metadata.level = 'info'`,
'severity.debug': `metadata.level = 'debug'`,
},
+ auth_logs: {
+ ..._SQL_FILTER_COMMON,
+ },
}
@@ -237,6 +240,7 @@ export enum LogsTableName {
POSTGRES = 'postgres_logs',
FUNCTIONS = 'function_logs',
FN_EDGE = 'function_edge_logs',
+ AUTH = 'auth_logs',
}
export const LOGS_TABLES = {
@@ -244,6 +248,7 @@ export const LOGS_TABLES = {
database: LogsTableName.POSTGRES,
functions: LogsTableName.FUNCTIONS,
fn_edge: LogsTableName.FN_EDGE,
+ auth: LogsTableName.AUTH
}
export const LOGS_SOURCE_DESCRIPTION = {
@@ -251,6 +256,7 @@ export const LOGS_SOURCE_DESCRIPTION = {
[LogsTableName.POSTGRES]: 'Database logs obtained directly from Postgres.',
[LogsTableName.FUNCTIONS]: 'Function logs generated from runtime execution.',
[LogsTableName.FN_EDGE]: 'Function call logs, containing the request and response.',
+ [LogsTableName.AUTH]: 'Authentication logs from GoTrue',
}
export const genCountQuery = (table: string): string => `SELECT count(*) as count FROM ${table}`
diff --git a/studio/components/interfaces/Settings/Logs/Logs.types.ts b/studio/components/interfaces/Settings/Logs/Logs.types.ts
index c5794102124..abcd8a14822 100644
--- a/studio/components/interfaces/Settings/Logs/Logs.types.ts
+++ b/studio/components/interfaces/Settings/Logs/Logs.types.ts
@@ -55,7 +55,7 @@ export type Count = LFResponse<CountData>
export type Logs = LFResponse<LogData>
-export type QueryType = 'api' | 'database' | 'functions' | 'fn_edge'
+export type QueryType = 'api' | 'database' | 'functions' | 'fn_edge' | "auth"
export type Mode = 'simple' | 'custom'
diff --git a/studio/components/interfaces/Settings/Logs/Logs.utils.ts b/studio/components/interfaces/Settings/Logs/Logs.utils.ts
index 13ad0208445..67511fed64a 100644
--- a/studio/components/interfaces/Settings/Logs/Logs.utils.ts
+++ b/studio/components/interfaces/Settings/Logs/Logs.utils.ts
@@ -148,7 +148,10 @@ export const genDefaultQuery = (table: LogsTableName, filters: Filters) => {
`
default:
- return ''
+ return `select id, ${table}.timestamp, event_message, metadata from ${table}
+ ${where}
+ limit 100
+ `
break
}
}
diff --git a/studio/components/layouts/AuthLayout/AuthLayout.utils.ts b/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
index 7ce9f4e3d68..87be6d53e21 100644
--- a/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
+++ b/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
@@ -9,6 +9,7 @@ export const generateAuthMenu = (ref: string): ProductMenuGroup[] => {
{ name: 'Users', key: 'users', url: `/project/${ref}/auth/users`, items: [] },
{ name: 'Policies', key: 'policies', url: `/project/${ref}/auth/policies`, items: [] },
{ name: 'Templates', key: 'templates', url: `/project/${ref}/auth/templates`, items: [] },
+ { name: 'Atuh Logs', key: 'templates', url: `/project/${ref}/auth/auth-logs`, items: [] },
],
},
...(IS_PLATFORM
diff --git a/studio/pages/project/[ref]/auth/auth-logs.tsx b/studio/pages/project/[ref]/auth/auth-logs.tsx
new file mode 100644
index 00000000000..65283a94a57
--- /dev/null
+++ b/studio/pages/project/[ref]/auth/auth-logs.tsx
@@ -0,0 +1,17 @@
+import { observer } from 'mobx-react-lite'
+import { withAuth, useStore } from 'hooks'
+import { AuthLayout } from 'components/layouts'
+import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer'
+
+const Auth = () => {
+ const { ui } = useStore()
+ const project = ui.selectedProject
+
+ return (
+ <AuthLayout title="Auth Logs">
+ {project && <LogsPreviewer projectRef={project!.ref} queryType="auth" />}
+ </AuthLayout>
+ )
+}
+
+export default withAuth(observer(Auth))