-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
feat(api): Workspace ip blacklisting #687
feat(api): Workspace ip blacklisting #687
Conversation
I'll review this once you are done. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
You are using user: user
at multiple places. We can replace it with just user
. You can do a grep search to find out such instances.
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.
Instead of having a separate endpoint and dto for the blacklisted ip modification, we should use a single update endpoint.
- If a non-empty array is passed, we update the list
- If an empty or undefined array is passed, we skip updating the list
To my understanding
|
Yeah, I didn't think about this perspective before |
We should be good to merge once you get the error fixed. |
I`ve already seen this issue before, but then could not reproduce it locally. Now after executing e2e tests locally, a completely different one failed in There seems to be some kind of race condition in e2e tests. I`ll look it up! |
Thanks!! |
@kriptonian1, could you take a look at this PR too, please? |
I cannot reproduce it locally. So far it has only occurred in the CI. |
Alright i'll look into it |
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (88.49%) is below the target coverage (98.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #687 +/- ##
===========================================
- Coverage 91.71% 87.36% -4.36%
===========================================
Files 111 118 +7
Lines 2510 3062 +552
Branches 469 452 -17
===========================================
+ Hits 2302 2675 +373
- Misses 208 387 +179
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@rajdip-b, what can I do here to have this PR merged? |
I'm not getting much time to sit an have a look at it. i dont think there is much to be done from your end. maybe in the meantime you can go through the test coverage and add more tests if needed. |
i think if you can just resolve the conflicts, we would be good to merge. i dont see any test failures |
431bab0
to
d93f71f
Compare
387f904
to
c78524b
Compare
c78524b
to
7eb3c78
Compare
## [2.12.0-stage.6](v2.12.0-stage.5...v2.12.0-stage.6) (2025-02-19) ### 🚀 Features * **api:** Workspace ip blacklisting ([#687](#687)) ([bc5f6a5](bc5f6a5))
🎉 This PR is included in version 2.12.0-stage.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
User description
Description
Implemented workspace IP blacklisting in order to enforce security of workspaces by blocking users from accessing them when their IP addresses are in the blacklist.
Fixes #127
Developer's checklist
If changes are made in the code:
Documentation Update
PR Type
Enhancement, Tests, Configuration changes
Description
Introduced workspace IP blacklisting to enhance security by restricting access based on IP addresses.
Replaced
AuthorityCheckerService
with a new centralizedAuthorizationService
across multiple services and controllers.Added endpoints and DTOs for managing blacklisted IP addresses in workspaces.
Updated user type to
AuthenticatedUser
with support for IP address handling.Enhanced authorization logic and streamlined service operations for better maintainability.
Added end-to-end and unit tests to verify the new IP blacklisting functionality and updated authorization logic.
Updated Prisma schema and added a migration to include
blacklistedIpAddresses
in theWorkspace
model.Changes walkthrough 📝
31 files
authority-checker.service.ts
Refactor authority checker service for improved workspace handling.
apps/api/src/auth/service/authority-checker.service.ts
AuthorizationParams
instead ofAuthorityInput
.getWorkspace
for fetching workspacedetails.
PrismaService
directly instead of passingit as a parameter.
project.service.ts
Migrate project service to use AuthorizationService.
apps/api/src/project/service/project.service.ts
AuthorityCheckerService
withAuthorizationService
forauthorization checks.
User
toAuthenticatedUser
throughout theservice.
prisma
parameter.variable.service.ts
Refactor variable service to use AuthorizationService.
apps/api/src/variable/service/variable.service.ts
AuthorityCheckerService
withAuthorizationService
forauthorization checks.
User
toAuthenticatedUser
.workspace.service.ts
Add IP blacklisting and refactor workspace service.
apps/api/src/workspace/service/workspace.service.ts
workspaces.
AuthorityCheckerService
withAuthorizationService
.User
toAuthenticatedUser
.secret.service.ts
Refactor secret service to use AuthorizationService.
apps/api/src/secret/service/secret.service.ts
AuthorityCheckerService
withAuthorizationService
.User
toAuthenticatedUser
.workspace-membership.service.ts
Refactor workspace membership service to use AuthorizationService.
apps/api/src/workspace-membership/service/workspace-membership.service.ts
AuthorityCheckerService
withAuthorizationService
.User
toAuthenticatedUser
.logic.
integration.service.ts
Refactor integration service to use AuthorizationService.
apps/api/src/integration/service/integration.service.ts
AuthorityCheckerService
withAuthorizationService
.User
toAuthenticatedUser
.authorization.service.ts
Add centralized AuthorizationService with IP restrictions.
apps/api/src/auth/service/authorization.service.ts
AuthorizationService
for centralized authorizationlogic.
environments, variables, secrets, and integrations.
environment.service.ts
Refactor environment service to use AuthorizationService.
apps/api/src/environment/service/environment.service.ts
AuthorityCheckerService
withAuthorizationService
.User
toAuthenticatedUser
.workspace-role.service.ts
Refactor workspace role service to use AuthorizationService.
apps/api/src/workspace-role/service/workspace-role.service.ts
AuthorityCheckerService
withAuthorizationService
.User
toAuthenticatedUser
.logic.
workspace-membership.controller.ts
Update workspace membership controller for new authorization.
apps/api/src/workspace-membership/controller/workspace-membership.controller.ts
AuthenticatedUser
type.AuthorizationService
.project.controller.ts
Update project controller for new authorization.
apps/api/src/project/controller/project.controller.ts
AuthenticatedUser
type.AuthorizationService
.auth.guard.ts
Update AuthGuard to include user IP address.
apps/api/src/auth/guard/auth/auth.guard.ts
AuthGuard
to include IP address inAuthenticatedUser
context.workspace.controller.ts
Add IP blacklisting endpoints to workspace controller.
apps/api/src/workspace/controller/workspace.controller.ts
AuthenticatedUser
type.AuthorizationService
for workspace operations.variable.controller.ts
Update variable controller for new authorization.
apps/api/src/variable/controller/variable.controller.ts
AuthenticatedUser
type.AuthorizationService
.secret.controller.ts
Update secret controller for new authorization.
apps/api/src/secret/controller/secret.controller.ts
AuthenticatedUser
type.AuthorizationService
.change-notifier.socket.ts
Refactor change notifier to use AuthorizationService.
apps/api/src/socket/change-notifier.socket.ts
AuthorityCheckerService
withAuthorizationService
.AuthenticatedUser
type.workspace-role.controller.ts
Update workspace role controller for new authorization.
apps/api/src/workspace-role/controller/workspace-role.controller.ts
AuthenticatedUser
type.AuthorizationService
.update.blacklistedIpAddresses.ts
Add DTO for workspace blacklisted IP addresses.
apps/api/src/workspace/dto/update.blacklistedIpAddresses/update.blacklistedIpAddresses.ts
integration.controller.ts
Update integration controller to use `AuthenticatedUser`.
apps/api/src/integration/controller/integration.controller.ts
User
withAuthenticatedUser
in method parameters.AuthenticatedUser
.environment.controller.ts
Update environment controller to use `AuthenticatedUser`.
apps/api/src/environment/controller/environment.controller.ts
User
withAuthenticatedUser
in method parameters.AuthenticatedUser
.environment.ts
Refactor environment utilities to use `AuthorizationService`.
apps/api/src/common/environment.ts
AuthorityCheckerService
withAuthorizationService
.AuthenticatedUser
.auth.module.ts
Enhance auth module with authorization services.
apps/api/src/auth/auth.module.ts
AuthorizationService
andAuthorityCheckerService
as providers.AuthorizationService
.event.service.ts
Refactor event service to use `AuthorizationService`.
apps/api/src/event/service/event.service.ts
AuthorityCheckerService
withAuthorizationService
.AuthenticatedUser
.event.controller.ts
Update event controller to use `AuthenticatedUser`.
apps/api/src/event/controller/event.controller.ts
AuthenticatedUser
.event.ts
Update event utilities for `AuthenticatedUser`.
apps/api/src/common/event.ts
AuthenticatedUser
.user.decorator.ts
Update `CurrentUser` decorator for `AuthenticatedUser`.
apps/api/src/decorators/user.decorator.ts
AuthenticatedUser
instead ofUserWithWorkspace
.common.module.ts
Simplify common module by removing unused service.
apps/api/src/common/common.module.ts
AuthorityCheckerService
from providers and exports.authorization.types.ts
Add types for authorization service.
apps/api/src/auth/service/authorization.types.ts
auth.types.ts
Extend auth types with IP address.
apps/api/src/auth/auth.types.ts
ipAddress
toAuthenticatedUserContext
.user.types.ts
Add `AuthenticatedUser` type definition.
apps/api/src/user/user.types.ts
AuthenticatedUser
interface withipAddress
.30 files
workspace.e2e.spec.ts
Add e2e tests for workspace IP blacklisting.
apps/api/src/workspace/workspace.e2e.spec.ts
AuthenticatedUser
type.project.e2e.spec.ts
Update project e2e tests for new authorization.
apps/api/src/project/project.e2e.spec.ts
AuthenticatedUser
type.variable.e2e.spec.ts
Update variable e2e tests for new authorization.
apps/api/src/variable/variable.e2e.spec.ts
AuthenticatedUser
type.integration.e2e.spec.ts
Modify integration e2e tests for `AuthenticatedUser`.
apps/api/src/integration/integration.e2e.spec.ts
AuthenticatedUser
.ipAddress
to user objects.secret.e2e.spec.ts
Modify secret e2e tests for `AuthenticatedUser`.
apps/api/src/secret/secret.e2e.spec.ts
AuthenticatedUser
.ipAddress
to user objects.environment.e2e.spec.ts
Modify environment e2e tests for `AuthenticatedUser`.
apps/api/src/environment/environment.e2e.spec.ts
AuthenticatedUser
.ipAddress
to user objects.event.e2e.spec.ts
Modify event e2e tests for `AuthenticatedUser`.
apps/api/src/event/event.e2e.spec.ts
AuthenticatedUser
.ipAddress
to user object.workspace-role.e2e.spec.ts
Modify workspace role e2e tests for `AuthenticatedUser`.
apps/api/src/workspace-role/workspace-role.e2e.spec.ts
AuthenticatedUser
.ipAddress
to user objects.workspace-membership.e2e.spec.ts
Modify workspace membership e2e tests for `AuthenticatedUser`.
apps/api/src/workspace-membership/workspace-membership.e2e.spec.ts
AuthenticatedUser
.ipAddress
to user objects.secret.controller.spec.ts
Update secret controller tests for authorization changes.
apps/api/src/secret/controller/secret.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.variable.controller.spec.ts
Update variable controller tests for authorization changes.
apps/api/src/variable/controller/variable.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.user.e2e.spec.ts
Add IP address handling in user e2e tests.
apps/api/src/user/user.e2e.spec.ts
ipAddress
to user objects in tests.secret.service.spec.ts
Update secret service tests for authorization changes.
apps/api/src/secret/service/secret.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.variable.service.spec.ts
Update variable service tests for authorization changes.
apps/api/src/variable/service/variable.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.integration.controller.spec.ts
Update integration controller tests for authorization changes.
apps/api/src/integration/controller/integration.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.environment.controller.spec.ts
Update environment controller tests for authorization changes.
apps/api/src/environment/controller/environment.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.event.controller.spec.ts
Update event controller tests for authorization changes.
apps/api/src/event/controller/event.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.project.controller.spec.ts
Update project controller tests for authorization changes.
apps/api/src/project/controller/project.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.project.service.spec.ts
Update project service tests for authorization changes.
apps/api/src/project/service/project.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.integration.service.spec.ts
Update integration service tests for authorization changes.
apps/api/src/integration/service/integration.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.environment.service.spec.ts
Update environment service tests for authorization changes.
apps/api/src/environment/service/environment.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.workspace-role.controller.spec.ts
Update workspace role controller tests for authorization changes.
apps/api/src/workspace-role/controller/workspace-role.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.workspace-membership.controller.spec.ts
Update workspace membership controller tests for authorization
changes.
apps/api/src/workspace-membership/controller/workspace-membership.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.event.service.spec.ts
Update event service tests for authorization changes.
apps/api/src/event/service/event.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.workspace-role.service.spec.ts
Update workspace role service tests for authorization changes.
apps/api/src/workspace-role/service/workspace-role.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.workspace-membership.service.spec.ts
Update workspace membership service tests for authorization changes.
apps/api/src/workspace-membership/service/workspace-membership.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.authorization.service.spec.ts
Add unit tests for `AuthorizationService`.
apps/api/src/auth/service/authorization.service.spec.ts
AuthorizationService
.workspace.controller.spec.ts
Update workspace controller tests for authorization changes.
apps/api/src/workspace/controller/workspace.controller.spec.ts
AuthorityCheckerService
withAuthorizationService
.workspace.service.spec.ts
Update workspace service tests for authorization changes.
apps/api/src/workspace/service/workspace.service.spec.ts
AuthorityCheckerService
withAuthorizationService
.update.blacklistedIpAddresses.spec.ts
Add unit test for blacklisted IP addresses DTO.
apps/api/src/workspace/dto/update.blacklistedIpAddresses/update.blacklistedIpAddresses.spec.ts
UpdateBlacklistedIpAddresses
DTO.1 files
instrumentation.ts
Minor formatting changes in instrumentation file.
apps/web/src/instrumentation.ts
2 files
schema.prisma
Extend workspace schema with blacklisted IP addresses.
apps/api/src/prisma/schema.prisma
blacklistedIpAddresses
field toWorkspace
model.migration.sql
Add migration for blacklisted IP addresses in workspace.
apps/api/src/prisma/migrations/20250206070313_add_blacklisted_ip_addresses_in_workspace/migration.sql
blacklistedIpAddresses
inWorkspace
.