Skip to content

chore(RFC): open core module system v1 #1063

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

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from

Conversation

StarpTech
Copy link
Contributor

@StarpTech StarpTech commented Aug 11, 2024

Motivation and Context

Related work:

TODO

@jensneuse
Copy link
Member

jensneuse commented Aug 11, 2024

A few goals I'd like to see covered:

  • load my own config from my own config provider
  • modify any config after load but before using it for a new mix
  • allow the user to customize the transport (we're currently wrapping the default transport, let the user bring their own)
  • hook into events like normalization, validation, parse (before, after)
  • allow the user to define additional validation rules/steps
  • Ideally, calling hooks is built in a way that automatically generates meaningful traces so that we're able to understand if and how much time the Router spends in a hook
  • it should be easy to create a custom module / plugin as a go module which can then be imported and configured easily, making it simple to re-use and share custom extensions
  • it would be nice if each module had it's own namespace (mandatory), like a prefix, so that the module can easily extend the existing Router config.yaml with it's own configuration without conflicts
  • it should be possible to define custom authentication hooks
  • it should be possible to define custom authorization hooks
  • it should be possible to define custom rate limit hooks

Additional comments:
Should we call it Gateway or Router? We talk a lot about Router, should we stick to this convention?

I'll look more into the RFC and give more specific feedback later/tomorrow.


## Custom Authentication and Authorization

Custom modules can be used to implement custom authentication and authorization logic in the router. The module can intercept incoming requests and validate the user's credentials, scopes, and permissions before forwarding the request to the subgraph. The router has built-in support for JWK. The parsed token information is available in the request `req.Request.Auth` field.

Choose a reason for hiding this comment

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

I would suggest supporting the scenario where you only want to customize authentication but still use the built in authorization via directives (such as requiresScopes). For example, if I sign my JWT using an algorithm that Cosmo doesn't support, I would like to build a custom auth plugin that validates the JWT and injects the claims/scopes into the context, so that Cosmo can authorize access using the directives in the schema.

@github-actions github-actions bot added the Stale label Dec 3, 2024
@wundergraph wundergraph deleted a comment from github-actions bot Dec 3, 2024
@StarpTech StarpTech removed the Stale label Dec 3, 2024
@github-actions github-actions bot added the Stale label Dec 18, 2024
@wundergraph wundergraph deleted a comment from github-actions bot Dec 18, 2024
@StarpTech StarpTech removed the Stale label Dec 18, 2024
@github-actions github-actions bot added the Stale label Jan 2, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Jan 2, 2025
@github-actions github-actions bot removed the Stale label Jan 3, 2025

// OperationHooks are called when an operation is parsed, normalized, or planned

type GraphQLOperationParseHook interface {
Copy link

Choose a reason for hiding this comment

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

Can we have add a GraphQLOperationPreParseHook? I am asking because I think we can use this new module system to implement Persisted Operations feature and PO fetching is done before parsing the operation.

@github-actions github-actions bot added the Stale label Jan 22, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Jan 22, 2025
@StarpTech StarpTech removed the Stale label Jan 22, 2025
@github-actions github-actions bot added the Stale label Feb 6, 2025
@StarpTech StarpTech removed the Stale label Feb 6, 2025
@github-actions github-actions bot added the Stale label Feb 21, 2025
@github-actions github-actions bot closed this Mar 7, 2025
@StarpTech StarpTech reopened this Mar 7, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Mar 7, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Mar 7, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Mar 7, 2025
@StarpTech StarpTech removed the Stale label Mar 7, 2025
@github-actions github-actions bot added the Stale label Mar 22, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Mar 22, 2025
@github-actions github-actions bot removed the Stale label Mar 23, 2025
@github-actions github-actions bot added the Stale label Apr 6, 2025
@wundergraph wundergraph deleted a comment from github-actions bot Apr 6, 2025
@StarpTech StarpTech removed the Stale label Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants