instantly-enterprise-rbac
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInstantly Enterprise RBAC
Instantly企业级RBAC
Overview
概述
Configure enterprise-grade access control for Instantly integrations.
为Instantly集成配置企业级访问控制。
Prerequisites
前提条件
- Instantly Enterprise tier subscription
- Identity Provider (IdP) with SAML/OIDC support
- Understanding of role-based access patterns
- Audit logging infrastructure
- Instantly企业版订阅
- 支持SAML/OIDC的身份提供商(IdP)
- 了解基于角色的访问模式
- 审计日志基础设施
Role Definitions
角色定义
| Role | Permissions | Use Case |
|---|---|---|
| Admin | Full access | Platform administrators |
| Developer | Read/write, no delete | Active development |
| Viewer | Read-only | Stakeholders, auditors |
| Service | API access only | Automated systems |
| 角色 | 权限 | 使用场景 |
|---|---|---|
| 管理员 | 完全访问 | 平台管理员 |
| 开发人员 | 读写权限,无删除权限 | 活跃开发场景 |
| 查看者 | 只读权限 | 利益相关者、审计人员 |
| 服务账号 | 仅API访问 | 自动化系统 |
Role Implementation
角色实现
typescript
enum InstantlyRole {
Admin = 'admin',
Developer = 'developer',
Viewer = 'viewer',
Service = 'service',
}
interface InstantlyPermissions {
read: boolean;
write: boolean;
delete: boolean;
admin: boolean;
}
const ROLE_PERMISSIONS: Record<InstantlyRole, InstantlyPermissions> = {
admin: { read: true, write: true, delete: true, admin: true },
developer: { read: true, write: true, delete: false, admin: false },
viewer: { read: true, write: false, delete: false, admin: false },
service: { read: true, write: true, delete: false, admin: false },
};
function checkPermission(
role: InstantlyRole,
action: keyof InstantlyPermissions
): boolean {
return ROLE_PERMISSIONS[role][action];
}typescript
enum InstantlyRole {
Admin = 'admin',
Developer = 'developer',
Viewer = 'viewer',
Service = 'service',
}
interface InstantlyPermissions {
read: boolean;
write: boolean;
delete: boolean;
admin: boolean;
}
const ROLE_PERMISSIONS: Record<InstantlyRole, InstantlyPermissions> = {
admin: { read: true, write: true, delete: true, admin: true },
developer: { read: true, write: true, delete: false, admin: false },
viewer: { read: true, write: false, delete: false, admin: false },
service: { read: true, write: true, delete: false, admin: false },
};
function checkPermission(
role: InstantlyRole,
action: keyof InstantlyPermissions
): boolean {
return ROLE_PERMISSIONS[role][action];
}SSO Integration
SSO集成
SAML Configuration
SAML配置
typescript
// Instantly SAML setup
const samlConfig = {
entryPoint: 'https://idp.company.com/saml/sso',
issuer: 'https://instantly.com/saml/metadata',
cert: process.env.SAML_CERT,
callbackUrl: 'https://app.yourcompany.com/auth/instantly/callback',
};
// Map IdP groups to Instantly roles
const groupRoleMapping: Record<string, InstantlyRole> = {
'Engineering': InstantlyRole.Developer,
'Platform-Admins': InstantlyRole.Admin,
'Data-Team': InstantlyRole.Viewer,
};typescript
// Instantly SAML setup
const samlConfig = {
entryPoint: 'https://idp.company.com/saml/sso',
issuer: 'https://instantly.com/saml/metadata',
cert: process.env.SAML_CERT,
callbackUrl: 'https://app.yourcompany.com/auth/instantly/callback',
};
// Map IdP groups to Instantly roles
const groupRoleMapping: Record<string, InstantlyRole> = {
'Engineering': InstantlyRole.Developer,
'Platform-Admins': InstantlyRole.Admin,
'Data-Team': InstantlyRole.Viewer,
};OAuth2/OIDC Integration
OAuth2/OIDC集成
typescript
import { OAuth2Client } from '@instantly/sdk';
const oauthClient = new OAuth2Client({
clientId: process.env.INSTANTLY_OAUTH_CLIENT_ID!,
clientSecret: process.env.INSTANTLY_OAUTH_CLIENT_SECRET!,
redirectUri: 'https://app.yourcompany.com/auth/instantly/callback',
scopes: ['read', 'write'],
});typescript
import { OAuth2Client } from '@instantly/sdk';
const oauthClient = new OAuth2Client({
clientId: process.env.INSTANTLY_OAUTH_CLIENT_ID!,
clientSecret: process.env.INSTANTLY_OAUTH_CLIENT_SECRET!,
redirectUri: 'https://app.yourcompany.com/auth/instantly/callback',
scopes: ['read', 'write'],
});Organization Management
组织管理
typescript
interface InstantlyOrganization {
id: string;
name: string;
ssoEnabled: boolean;
enforceSso: boolean;
allowedDomains: string[];
defaultRole: InstantlyRole;
}
async function createOrganization(
config: InstantlyOrganization
): Promise<void> {
await instantlyClient.organizations.create({
...config,
settings: {
sso: {
enabled: config.ssoEnabled,
enforced: config.enforceSso,
domains: config.allowedDomains,
},
},
});
}typescript
interface InstantlyOrganization {
id: string;
name: string;
ssoEnabled: boolean;
enforceSso: boolean;
allowedDomains: string[];
defaultRole: InstantlyRole;
}
async function createOrganization(
config: InstantlyOrganization
): Promise<void> {
await instantlyClient.organizations.create({
...config,
settings: {
sso: {
enabled: config.ssoEnabled,
enforced: config.enforceSso,
domains: config.allowedDomains,
},
},
});
}Access Control Middleware
访问控制中间件
typescript
function requireInstantlyPermission(
requiredPermission: keyof InstantlyPermissions
) {
return async (req: Request, res: Response, next: NextFunction) => {
const user = req.user as { instantlyRole: InstantlyRole };
if (!checkPermission(user.instantlyRole, requiredPermission)) {
return res.status(403).json({
error: 'Forbidden',
message: `Missing permission: ${requiredPermission}`,
});
}
next();
};
}
// Usage
app.delete('/instantly/resource/:id',
requireInstantlyPermission('delete'),
deleteResourceHandler
);typescript
function requireInstantlyPermission(
requiredPermission: keyof InstantlyPermissions
) {
return async (req: Request, res: Response, next: NextFunction) => {
const user = req.user as { instantlyRole: InstantlyRole };
if (!checkPermission(user.instantlyRole, requiredPermission)) {
return res.status(403).json({
error: 'Forbidden',
message: `Missing permission: ${requiredPermission}`,
});
}
next();
};
}
// Usage
app.delete('/instantly/resource/:id',
requireInstantlyPermission('delete'),
deleteResourceHandler
);Audit Trail
审计追踪
typescript
interface InstantlyAuditEntry {
timestamp: Date;
userId: string;
role: InstantlyRole;
action: string;
resource: string;
success: boolean;
ipAddress: string;
}
async function logInstantlyAccess(entry: InstantlyAuditEntry): Promise<void> {
await auditDb.insert(entry);
// Alert on suspicious activity
if (entry.action === 'delete' && !entry.success) {
await alertOnSuspiciousActivity(entry);
}
}typescript
interface InstantlyAuditEntry {
timestamp: Date;
userId: string;
role: InstantlyRole;
action: string;
resource: string;
success: boolean;
ipAddress: string;
}
async function logInstantlyAccess(entry: InstantlyAuditEntry): Promise<void> {
await auditDb.insert(entry);
// Alert on suspicious activity
if (entry.action === 'delete' && !entry.success) {
await alertOnSuspiciousActivity(entry);
}
}Instructions
操作步骤
Step 1: Define Roles
步骤1:定义角色
Map organizational roles to Instantly permissions.
将组织角色映射到Instantly权限。
Step 2: Configure SSO
步骤2:配置SSO
Set up SAML or OIDC integration with your IdP.
与您的IdP设置SAML或OIDC集成。
Step 3: Implement Middleware
步骤3:实现中间件
Add permission checks to API endpoints.
为API端点添加权限检查。
Step 4: Enable Audit Logging
步骤4:启用审计日志
Track all access for compliance.
跟踪所有访问以满足合规要求。
Output
输出结果
- Role definitions implemented
- SSO integration configured
- Permission middleware active
- Audit trail enabled
- 已实现角色定义
- 已配置SSO集成
- 权限中间件已激活
- 已启用审计追踪
Error Handling
错误处理
| Issue | Cause | Solution |
|---|---|---|
| SSO login fails | Wrong callback URL | Verify IdP config |
| Permission denied | Missing role mapping | Update group mappings |
| Token expired | Short TTL | Refresh token logic |
| Audit gaps | Async logging failed | Check log pipeline |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| SSO登录失败 | 回调URL错误 | 验证IdP配置 |
| 权限被拒绝 | 缺少角色映射 | 更新组映射 |
| 令牌过期 | TTL过短 | 实现令牌刷新逻辑 |
| 审计日志缺失 | 异步日志记录失败 | 检查日志管道 |
Examples
示例
Quick Permission Check
快速权限检查
typescript
if (!checkPermission(user.role, 'write')) {
throw new ForbiddenError('Write permission required');
}typescript
if (!checkPermission(user.role, 'write')) {
throw new ForbiddenError('Write permission required');
}Resources
参考资源
Next Steps
后续步骤
For major migrations, see .
instantly-migration-deep-dive如需进行大规模迁移,请查看。
instantly-migration-deep-dive