2
0

🛂 Auto ban IP on suspected bot publishing (#1095)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced sign-in error handling with specific messages for different
error types.
- Implemented IP-based restrictions for authentication and publishing
actions.

- **Bug Fixes**
- Updated the retrieval of user session information to improve
reliability.

- **Documentation**
- Updated usage instructions for `getServerSession` to reflect the new
authentication options.

- **Refactor**
- Replaced direct usage of `authOptions` with a new function
`getAuthOptions` to dynamically generate authentication options.
- Improved IP address extraction logic to handle various header formats.

- **Chores**
- Added a new `BannedIp` model to the database schema for managing
IP-based restrictions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Baptiste Arnaud
2023-12-11 13:40:07 +01:00
committed by GitHub
parent eedb7145ac
commit fcfbd63443
13 changed files with 171 additions and 38 deletions

View File

@@ -58,6 +58,7 @@ model User {
CollaboratorsOnTypebots CollaboratorsOnTypebots[]
workspaces MemberInWorkspace[]
sessions Session[]
bannedIps BannedIp[]
}
model ApiToken {
@@ -202,6 +203,7 @@ model Typebot {
isClosed Boolean @default(false)
whatsAppCredentialsId String?
riskLevel Int?
bannedIps BannedIp[]
@@index([workspaceId])
@@index([folderId])
@@ -361,6 +363,19 @@ model ThemeTemplate {
@@index([workspaceId])
}
model BannedIp {
id String @id @default(cuid())
createdAt DateTime @default(now())
ip String @unique
responsibleTypebot Typebot @relation(fields: [responsibleTypebotId], references: [id], onDelete: Restrict)
responsibleTypebotId String
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
userId String
@@index([responsibleTypebotId])
@@index([userId])
}
enum WorkspaceRole {
ADMIN
MEMBER