Skip to content

Add security policy to Engine-Only endpoints#2082

Merged
MarceloRGonc merged 6 commits intomainfrom
mg/engine-routes
Mar 6, 2026
Merged

Add security policy to Engine-Only endpoints#2082
MarceloRGonc merged 6 commits intomainfrom
mg/engine-routes

Conversation

@MarceloRGonc
Copy link
Contributor

@MarceloRGonc MarceloRGonc commented Mar 6, 2026

Fixes OPS-3866.

Comment on lines +50 to +53
config: {
allowedPrincipals: [PrincipalType.ENGINE],
security: ENGINE_ROUTE_POLICY,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file has a preHandler. So this is the same behavior.

app.addHook('preHandler', allowWorkersOnly);

export const allowWorkersOnly: onRequestHookHandler = (request, _res, done) => {
  if (request.principal.type !== PrincipalType.ENGINE) {
    throw new ApplicationError({
      code: ErrorCode.AUTHORIZATION,
      params: {},
    });
  }

  done();
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this file

@linear
Copy link

linear bot commented Mar 6, 2026

@MarceloRGonc MarceloRGonc changed the title Mg/engine routes Add security policy to Engine-Only Endpoints Mar 6, 2026
@MarceloRGonc MarceloRGonc changed the title Add security policy to Engine-Only Endpoints Add security policy to Engine-Only endpoints Mar 6, 2026
@MarceloRGonc MarceloRGonc marked this pull request as ready for review March 6, 2026 13:56
Copilot AI review requested due to automatic review settings March 6, 2026 13:56
Copy link
Contributor

Copilot AI left a 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 reusable “engine-only” security policy and applies it to Engine-only API endpoints to make their access rules explicit and consistent (OPS-3866).

Changes:

  • Add shared ENGINE_ROUTE_POLICY and supporting unscoped route/policy types in @openops/shared.
  • Attach config.security: ENGINE_ROUTE_POLICY to multiple engine-only endpoints (workers, store-entry, project worker, flags, app-connection worker).
  • Begin wiring shared UnscopedAuthorizationPolicy into the server route-policy type definitions.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/shared/src/lib/authentication/model/principal-type.ts Adds unscoped policy types and a shared ENGINE_ROUTE_POLICY.
packages/server/api/src/app/workers/engine-controller.ts Applies ENGINE_ROUTE_POLICY to engine worker endpoints.
packages/server/api/src/app/store-entry/store-entry.controller.ts Applies ENGINE_ROUTE_POLICY to store-entry endpoints.
packages/server/api/src/app/project/project-worker-controller.ts Applies ENGINE_ROUTE_POLICY to the project worker endpoint.
packages/server/api/src/app/flags/flag.module.ts Applies ENGINE_ROUTE_POLICY to the engine-only flags endpoint.
packages/server/api/src/app/core/security/route-policies/route-security-policy.ts Imports shared UnscopedAuthorizationPolicy (currently conflicting with a local type).
packages/server/api/src/app/app-connection/app-connection-worker-controller.ts Applies ENGINE_ROUTE_POLICY to the worker app-connection endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

@MarceloRGonc MarceloRGonc merged commit 6134e6a into main Mar 6, 2026
21 checks passed
@MarceloRGonc MarceloRGonc deleted the mg/engine-routes branch March 6, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants