Skip to content

Commit 101dd24

Browse files
committed
feat: Add SCIM 2.0 provisioning proto definitions
- Introduced `provisioning.proto` for automated user lifecycle management. - Defined `ProvisioningConfig`, `ProvisioningDirection`, and `ProvisioningStatus` messages with validation rules. refactor: Remove outdated webhook proto files - Deleted `README.md` and `messages.proto` from the webhook directory. - Introduced new `webhook.proto` with updated webhook subscription and delivery definitions. docs: Add comprehensive documentation for preference domain - Created `README.md` for the preference domain detailing user-level configurations. - Added `preferences.proto` for user preferences, including localization, notifications, privacy, and accessibility settings. chore: Implement scripts for plugin updates and documentation generation - Added `check-plugin-updates.sh` to check for available plugin updates. - Created `generate-docs.sh` to automate API documentation generation from proto files.
1 parent 5a5db60 commit 101dd24

File tree

278 files changed

+13491
-32306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+13491
-32306
lines changed

.github/copilot-instructions.md

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,34 +113,102 @@ rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
113113

114114
## Common Patterns
115115

116-
### Pagination (Use core.v1)
116+
### Pagination (Industry-Standard Cursor-Based)
117+
118+
**Single Responsibility:** Pagination only - sorting and filtering are separate concerns
117119

118120
```protobuf
119-
import "core/v1/common.proto";
121+
import "core/api/pagination/v1/messages.proto";
120122
121123
message ListUsersRequest {
122124
string tenant_id = 1;
123-
core.v1.PaginationRequest pagination = 2;
125+
126+
// Pagination (separate concern)
127+
core.api.pagination.v1.PaginationRequest pagination = 2;
128+
129+
// Sorting (Google AIP-132 - add directly to request)
130+
string order_by = 3; // e.g., "created_at desc"
131+
132+
// Filtering (Google AIP-160 - add directly to request)
133+
string filter = 4; // e.g., "status='active'"
124134
}
125135
126136
message ListUsersResponse {
127137
repeated User users = 1;
128-
core.v1.PaginationResponse pagination = 2;
138+
core.api.pagination.v1.PaginationResponse pagination = 2;
139+
}
140+
```
141+
142+
**Pagination uses cursor map with client-side caching:**
143+
144+
- First page: omit `cursor`, server returns cursor for next page
145+
- Next pages: provide cached `cursor` from previous response → O(log n) performance
146+
- Client caches cursors per page for bidirectional navigation
147+
- End of results: `cursor` is empty
148+
149+
**Sorting format (Google AIP-132 standard):**
150+
151+
- `"created_at desc"` - newest first
152+
- `"name"` - alphabetical ascending
153+
- `"priority desc, created_at"` - multi-field sort
154+
155+
### Entity Metadata Pattern (CRITICAL)
156+
157+
**All domain entities MUST include flattened audit fields for database efficiency.**
158+
159+
DO NOT use nested `core.metadata.v1.Metadata` message in entities. Use direct fields instead to support efficient search, filtering, and indexing in databases.
160+
161+
**Required Audit Fields Template:**
162+
163+
```protobuf
164+
message User {
165+
string user_id = 1;
166+
string tenant_id = 2;
167+
// ... domain-specific fields ...
168+
169+
// Created timestamp. IMMUTABLE after creation.
170+
// COMPLIANCE: SOC 2 CC6.3, GDPR Article 30 (audit trail)
171+
google.protobuf.Timestamp created_at = N [(buf.validate.field).required = true];
172+
173+
// Last updated timestamp.
174+
// COMPLIANCE: SOC 2 CC6.3 (change tracking)
175+
google.protobuf.Timestamp updated_at = N+1;
176+
177+
// Deletion timestamp. If set, entity is soft deleted.
178+
// COMPLIANCE: GDPR Article 17, SOC 2 CC6.3 (deletion audit trail)
179+
// QUERY: Use "WHERE deleted_at IS NULL" for active records
180+
google.protobuf.Timestamp deleted_at = N+2;
181+
182+
// Optimistic locking version counter. Incremented on each update.
183+
// COMPLIANCE: SOC 2 CC6.1 (data integrity, concurrent modification protection)
184+
int64 version = N+3;
129185
}
130186
```
131187

188+
**Rationale:** Flattened structure enables:
189+
190+
- Efficient database indexing on audit fields
191+
- Direct filtering/searching on created_at, updated_at, deleted_at
192+
- Better ORM mapping and query performance
193+
- Simplified database schema generation
194+
- Single source of truth for deletion (deleted_at IS NULL = active, IS NOT NULL = deleted)
195+
196+
**Note:** Actor tracking (created_by, updated_by) should be maintained in separate audit entity for detailed change history while keeping domain entities lean for frequent queries.
197+
132198
### Domain Events Pattern
133199

134200
```protobuf
135201
// UserCreated emitted when user account is successfully created.
136202
// EVENT: Publish to event bus for downstream consumers
137203
// COMPLIANCE: Audit trail requirement
138204
message UserCreated {
139-
core.v1.Metadata metadata = 1; // Event ID and timestamp
140-
string tenant_id = 2;
141-
string user_id = 3;
142-
string email = 4; // Safe for event - no password
143-
string created_by = 5;
205+
string event_id = 1; // UUID for event tracing
206+
google.protobuf.Timestamp event_timestamp = 2;
207+
string tenant_id = 3;
208+
string user_id = 4;
209+
string email = 5; // Safe for event - no password
210+
string created_by = 6;
211+
string correlation_id = 7; // For distributed tracing
144212
}
145213
```
146214

@@ -169,8 +237,8 @@ Before committing:
169237

170238
## Common Gotchas
171239

172-
1. **Don't modify `deprecated/` directory** - it's frozen legacy code
173-
2. **Check if domain exists** - Use `proto/idp/` for auth, not deprecated `proto/auth/`
240+
1. **Package naming** - Use domain-first for IDP: `geniustechspace.idp.{domain}.{subdomain}.{layer}.v1`
241+
2. **Check if domain exists** - Use `proto/idp/` for identity and auth operations
174242
3. **Empty directories** - `proto/idp/authn/v1/`, `proto/core/[subdomain]/` may be empty; check README location
175243
4. **Import paths** - Always module-relative, never absolute with `proto/` prefix
176244
5. **Tenant isolation** - Every request MUST have tenant_id; every service MUST enforce it
@@ -182,7 +250,7 @@ Before committing:
182250
1. Create directory: `proto/newdomain/v1/`
183251
2. Create modular files: `messages.proto`, `service.proto`, `events.proto`, `enums.proto`
184252
3. Add domain README explaining purpose and patterns
185-
4. Include Metadata in all entities
253+
4. Include flattened audit fields in all entities (created_at, updated_at, deleted_at, version)
186254
5. Include tenant_id in all requests
187255
6. Add protovalidate annotations
188256
7. Document compliance requirements
@@ -191,7 +259,7 @@ Before committing:
191259

192260
## Additional Resources
193261

194-
- Buf docs: https://buf.build/docs
195-
- Protovalidate: https://github.com/bufbuild/protovalidate
196-
- gRPC style guide: https://grpc.io/docs/guides/
262+
- Buf docs: <https://buf.build/docs>
263+
- Protovalidate: <https://github.com/bufbuild/protovalidate>
264+
- gRPC style guide: <https://grpc.io/docs/guides/>
197265
- Domain-driven design applied to this repo: Check modular IDP structure in `proto/idp/`

0 commit comments

Comments
 (0)