Skip to content

Commit

Permalink
docs: refine tone and messaging
Browse files Browse the repository at this point in the history
- Focus on speed and scalability
- Remove enterprise terminology
- Add concrete performance tips
- Emphasize quick time-to-value
- Streamline multi-tenant setup
- Improve code examples
  • Loading branch information
david-r-cox committed Dec 17, 2024
1 parent 1398227 commit 56c88b8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 92 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# KeyHippo

Add powerful, secure API key authentication to your Supabase project.
Industrial-strength API key auth for modern Postgres applications.

<!-- markdownlint-disable-next-line -->
<div align="center">
Expand All @@ -13,15 +13,15 @@ Add powerful, secure API key authentication to your Supabase project.

## What is KeyHippo?

KeyHippo extends Supabase with industrial-strength API key authentication that works seamlessly with Row Level Security (RLS) and Role-Based Access Control (RBAC).
KeyHippo adds production-ready API key authentication to Supabase that works seamlessly with Row Level Security (RLS) and Role-Based Access Control (RBAC).

### Key Features

- **Easy Integration**: Works directly with your existing Supabase setup
- **🔒 Security First**: Zero plaintext storage, high-entropy keys, audit logging
- **🎯 Fine-Grained Control**: Tenant isolation, role-based access, custom claims
- **⚡ High Performance**: Pure SQL implementation, optimized queries
- **🛠️ Developer Friendly**: Clear APIs, comprehensive docs, real-world patterns
- **Instant Setup**: 2-minute setup, immediate value
- **🔒 Production Ready**: Built-in audit logs, key rotation, tenant isolation
- **🎯 Scale With You**: From prototype to millions of users
- **⚡ High Performance**: Pure SQL, no extra services
- **🛠️ Developer Experience**: Clear APIs, real examples, zero friction

## Quick Start

Expand Down Expand Up @@ -69,16 +69,16 @@ curl -X GET 'https://your-project.supabase.co/rest/v1/resources' \
## Documentation

### Getting Started
- [🚀 QuickStart Guide](docs/guides/quickstart.md) - Basic setup and usage
- [🏢 Enterprise Guide](docs/guides/enterprise_quickstart.md) - Multi-tenant setup
- [🚀 5-Minute Quickstart](docs/guides/quickstart.md) - From zero to working API keys
- [🏢 Multi-Tenant Setup](docs/guides/multi_tenant_quickstart.md) - Scale with your user base

### Implementation Guides
- [🔑 API Key Patterns](docs/guides/api_key_patterns.md) - Common implementation patterns
- [🏠 Multi-Tenant Guide](docs/guides/multi_tenant.md) - Tenant isolation patterns
- [🔑 API Key Patterns](docs/guides/api_key_patterns.md) - Real-world implementation patterns
- [🏠 Tenant Isolation](docs/guides/multi_tenant.md) - Clean multi-tenant architecture

### Reference
- [📚 API Documentation](docs/api/index.md) - Complete API reference
- [🛡️ Security Guide](docs/api/security/rls_policies.md) - Security best practices
- [🛡️ Security Guide](docs/api/security/rls_policies.md) - Production security

## Development

Expand Down Expand Up @@ -113,7 +113,7 @@ We welcome contributions! Before submitting a PR:
- [📝 Issues](https://github.com/integrated-reasoning/KeyHippo/issues) - Bug reports and features
- [🤝 Discussions](https://github.com/integrated-reasoning/KeyHippo/discussions) - Questions and ideas
- [🔒 Security](SECURITY.md) - Vulnerability reporting
- [💼 Enterprise](https://keyhippo.com) - Commercial support
- [💼 Pro Support](https://keyhippo.com) - Priority support & custom features

## License

Expand Down
2 changes: 1 addition & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# KeyHippo API Reference

Complete reference documentation for KeyHippo's API.
Production-ready API reference for fast-moving teams.

## Core Concepts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
# Enterprise QuickStart Guide
# Multi-Tenant Quickstart

Implementation guide for setting up KeyHippo in a multi-tenant enterprise environment.
Scale your application with clean tenant isolation and robust access controls.

## Prerequisites

- PostgreSQL 14 or higher
- Supabase Enterprise or self-hosted setup
- Database superuser access
- Basic understanding of RBAC concepts

## Architecture Overview
## Overview

```mermaid
graph TD
Expand All @@ -20,7 +13,7 @@ graph TD
F[Admin] -->|Impersonation| B
```

## Installation
## Setup

1. Install dependencies:
```sql
Expand All @@ -34,7 +27,7 @@ CREATE EXTENSION IF NOT EXISTS pg_cron;
\i sql/keyhippo.sql
```

## Tenant Setup
## Tenant Architecture

1. Create tenant tables:
```sql
Expand All @@ -59,41 +52,7 @@ ALTER TABLE tenants ENABLE ROW LEVEL SECURITY;
ALTER TABLE tenant_members ENABLE ROW LEVEL SECURITY;
```

## RBAC Configuration

1. Create tenant-specific groups:
```sql
DO $$
DECLARE
tenant_group_id uuid;
BEGIN
-- Create tenant admin group
SELECT keyhippo_rbac.create_group(
'Tenant Administrators',
'Tenant-level administrative access'
) INTO tenant_group_id;

-- Create admin role
PERFORM keyhippo_rbac.create_role(
'Tenant Admin',
'Full tenant access',
tenant_group_id,
'admin'
);
END $$;
```

2. Set up permissions:
```sql
-- Add tenant management permissions
INSERT INTO keyhippo_rbac.permissions (name, description)
VALUES
('tenant:admin', 'Full tenant access'),
('tenant:member', 'Basic tenant access'),
('tenant:read', 'Read-only tenant access');
```

## Access Control Implementation
## Access Control

1. Create tenant access function:
```sql
Expand Down Expand Up @@ -142,7 +101,7 @@ CREATE POLICY resource_tenant_policy ON resource_table
USING (has_tenant_access(tenant_id));
```

## API Key Management
## API Keys

1. Create tenant-specific API key:
```sql
Expand Down Expand Up @@ -181,7 +140,7 @@ END;
$$;
```

## Monitoring Setup
## Security

1. Enable audit logging:
```sql
Expand All @@ -192,40 +151,17 @@ VALUES
('audit_retention_days', '90');
```

2. Create audit views:
```sql
CREATE VIEW tenant_audit_log AS
SELECT
a.*,
(a.data->'claims'->>'tenant_id')::uuid as tenant_id
FROM keyhippo.audit_log a
WHERE a.data ? 'tenant_id';
```

## Security Hardening

1. Configure key expiration:
2. Configure key expiration:
```sql
-- Set default key expiration to 90 days
UPDATE keyhippo_internal.config
SET value = '90'
WHERE key = 'key_expiry_notification_hours';
```

2. Enable automatic key rotation:
```sql
SELECT cron.schedule(
'rotate-tenant-keys',
'0 0 * * 0',
$$
SELECT rotate_expired_tenant_keys();
$$
);
```

## Testing Setup
## Testing

1. Create test tenant:
1. Set up test data:
```sql
DO $$
DECLARE
Expand All @@ -234,7 +170,7 @@ DECLARE
BEGIN
-- Create test tenant
INSERT INTO tenants (name)
VALUES ('Test Tenant')
VALUES ('Acme Corp')
RETURNING id INTO tenant_id;

-- Create test user
Expand All @@ -248,7 +184,7 @@ BEGIN
END $$;
```

2. Verify setup:
2. Test the setup:
```sql
-- Create test API key
SELECT create_tenant_api_key(
Expand All @@ -260,6 +196,28 @@ SELECT create_tenant_api_key(
SELECT has_tenant_access('tenant_id_here');
```

## Performance Tips

1. **Index Critical Fields**
```sql
CREATE INDEX idx_tenant_members_user_id
ON tenant_members(user_id);

CREATE INDEX idx_resources_tenant_id
ON resources(tenant_id);
```

2. **Batch Operations**
```sql
-- Example: Bulk user assignment
INSERT INTO tenant_members (tenant_id, user_id, role)
SELECT
tenant_id,
unnest(user_ids) as user_id,
'member' as role
FROM json_array_elements_text('["user1", "user2"]') as user_ids;
```

## Next Steps

- Implement [Custom Claims](../api/functions/update_key_claims.md)
Expand All @@ -268,6 +226,6 @@ SELECT has_tenant_access('tenant_id_here');

## Related Resources

- [Multi-Tenant Guide](multi_tenant.md)
- [API Key Patterns](api_key_patterns.md)
- [Multi-Tenant Guide](multi_tenant.md)
- [Security Best Practices](../api/security/rls_policies.md)

0 comments on commit 56c88b8

Please sign in to comment.