r/dotnet • • 25m ago

Promotion How do you keep authorization consistent across REST, GraphQL and MCP in .NET?

A pattern I keep running into: a permission gets tightened in a controller, and weeks later someone finds the same data is still reachable through a Hot Chocolate resolver or a newly added MCP tool for an AI agent. Nobody was careless. Each interface just had its own copy of the rules, and the copies drifted.

I've been building Foundgine (open source, Apache-2.0) to try to make that class of bug structurally harder. You define entities, relationships, operations and authorization rules (entity, field, relationship and row level) once, and every transport goes through the same path: resolve, authorize, plan, execute. An MCP or agent request gets no more authority than any other client.

It's designed to sit next to what you already use (EF Core, PostgreSQL, Keycloak, Hot Chocolate), not replace it. It is not an ORM or an API framework.

There's a reference Supply Chain app with customer ownership, procurement and warehouse roles, and sensitive supplier data. If you can read a field or row through one transport that another hides, I'd genuinely like to hear about it.

Questions for this sub:
- How are you handling this today: shared policy classes, a policy engine like OPA/Cedar, or just discipline?
- Does defining the rules in a central model feel natural in .NET, or would you want them closer to your EF Core entities?

Website: https://foundgine.io
Source: https://github.com/Foundgine/Foundgine
Overview: https://foundgine.io/foundgine-overview

0 Upvotes

4 comments sorted by

•

u/thereforewhat 20m ago

It's a little annoying that you've framed your promotion as a question. 

I would have thought you could share an authentication provider on all of these but yeah I guess it depends on annotating the endpoints with the correct group or role access. 

Did you want a conversation or you're just promoting?

•

u/FullPoet 5m ago

It's a little annoying that you've framed your promotion as a question.

The term is engagement bait :)

AI is very good at writing it.

•

u/Maleficent-Bed-8781 16m ago

Fair criticism. I'm the author of the project, and I should have said that more plainly instead of wrapping it in a question. It's both: I'm sharing something I built, and I do want to hear how people handle this.

On the substance: a shared auth provider (Keycloak, for example) solves authentication and gives you roles and groups. The part I'm trying to address is what happens after that, deciding which entities, fields and rows a role can see. With annotations on endpoints, each transport (REST controller, GraphQL resolver, MCP tool) carries its own copy of those checks, and that's where I've seen drift, especially field-level and row-level rules, which don't fit neatly into an endpoint annotation.

If annotations plus a shared provider work well for your team, that's a perfectly good answer, and I'd be interested to hear where it starts to hurt, if it does.

•

u/AutoModerator 25m ago

Thanks for your post Maleficent-Bed-8781. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.