-
Notifications
You must be signed in to change notification settings - Fork 166
Add RefreshToken model and database entity
#1791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new IntegrationAuthorization model and corresponding database infrastructure to track user authorizations for external integrations.
Key Changes:
- Added
IntegrationAuthorizationTypeBox schema model with fields for user, project, organization, token, integration name, and revocation status - Created database entity with foreign key relationships and composite index on projectId and integrationName
- Implemented database migration to create the integration_authorization table
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/lib/integration-authorization/integration-authorization.ts | Defines the IntegrationAuthorization TypeBox schema with required fields |
| packages/shared/src/index.ts | Exports the new IntegrationAuthorization model |
| packages/server/api/src/app/integration-authorization/integration-authorization.entity.ts | Creates TypeORM entity schema with relations and composite index |
| packages/server/api/src/app/database/postgres-connection.ts | Registers the migration in the migrations list |
| packages/server/api/src/app/database/migrations/1766579857000-CreateIntegrationAuthorizationTable.ts | Implements database migration to create the table with foreign keys and index |
| packages/server/api/src/app/database/database-connection.ts | Adds IntegrationAuthorizationEntity to the list of registered entities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/server/api/src/app/integration-authorization/integration-authorization.entity.ts
Outdated
Show resolved
Hide resolved
packages/server/api/src/app/integration-authorization/integration-authorization.entity.ts
Outdated
Show resolved
Hide resolved
packages/server/api/src/app/integration-authorization/integration-authorization.entity.ts
Outdated
Show resolved
Hide resolved
packages/server/api/src/app/integration-authorization/integration-authorization.entity.ts
Outdated
Show resolved
Hide resolved
.../server/api/src/app/database/migrations/1766579857000-CreateIntegrationAuthorizationTable.ts
Outdated
Show resolved
Hide resolved
.../server/api/src/app/database/migrations/1766579857000-CreateIntegrationAuthorizationTable.ts
Outdated
Show resolved
Hide resolved
.../server/api/src/app/database/migrations/1766579857000-CreateIntegrationAuthorizationTable.ts
Outdated
Show resolved
Hide resolved
…d database entity.
IntegrationAuthorization model and database entityRefreshToken model and database entity
| "principal" jsonb NOT NULL, | ||
| "is_revoked" boolean NOT NULL DEFAULT false, | ||
| "revoked_at" TIMESTAMP WITH TIME ZONE, | ||
| "expirationTime" TIMESTAMP WITH TIME ZONE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be not null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, i think we need to keep an option for tokens without expiration date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need tokens that don't expire?
packages/server/api/src/app/database/migrations/1766579857000-CreateRefreshTokenTable.ts
Outdated
Show resolved
Hide resolved
| await queryRunner.query(` | ||
| CREATE INDEX IF NOT EXISTS "idx_refresh_token_project_id_and_client" ON "refresh_token" ("projectId", "client") | ||
| `); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing constraints:
- Unique refreshToken
- Unique refreshToken, projectId, userId, client, isRevoked false
packages/server/api/src/app/database/migrations/1766579857000-CreateRefreshTokenTable.ts
Outdated
Show resolved
Hide resolved
packages/server/api/src/app/database/migrations/1766579857000-CreateRefreshTokenTable.ts
Outdated
Show resolved
Hide resolved
packages/server/api/src/app/database/migrations/1766579857000-CreateRefreshTokenTable.ts
Outdated
Show resolved
Hide resolved
packages/server/api/src/app/database/migrations/1766579857000-CreateRefreshTokenTable.ts
Show resolved
Hide resolved
…CreateRefreshTokenTable.ts Co-authored-by: Marcelo Gonçalves <marcelo@openops.com>
|



Fixes OPS-2994.