Skip to content

Improve tRPC auth handling #420

Description

@alexanderpaolini

The way tRPC handles auth right now is a bit strange. We call a permProcedure and then in the mutation/query, we call permissions.controlPerms.or(["...PERM..."], ctx);. This is kind of funky and can be cleaned up into better ways.

Dhruv and I were discussing changing this to a middleware. This would allow us to do something similar to

permProcedure
  .use(permsMiddleware("OR", ["SOME_PERM", "SOME_OTHER_PERM"]))
  .input(/* ts don't matter */)
  .mutation(/* ts don't matter either */)

The naming can obviously be changed but this is a better pattern to stick to. Since we are using side effect functions rather than a middleware right now. This refactor wouldn't be too complex, but it would touch a large majority of our API. Opening this issue so we can discuss this in the future.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIChange modifies code in the global API/tRPC packageMinorSmall change - 1 reviewer required

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions