Robyn icon indicating copy to clipboard operation
Robyn copied to clipboard

Feat: add auth subroutes capabilities

Open IA-PieroCV opened this issue 1 year ago • 6 comments

Description

This PR fixes #708

Summary

This PR does handle authentication for subroutes having different levels of precedence:

  1. Endpoint decorators have highest precedence.
  2. include_router has the second highest precedence.
  3. SubRoute instance has the lowest precedence.
  4. If None of the above is specified, the default is False.

This PR change auth logic:

  • It does add an auth_required parameter for Route objects.
  • The authentication middleware is evaluated first and added before starting the server.
    • This ensures that precedence is made correctly.

Several integration tests were provided. MDX documentation was also updated. To be discussed on #1026

PR Checklist

Please ensure that:

  • [X] The PR contains a descriptive title
  • [X] The PR contains a descriptive summary of the changes
  • [X] You build and test your changes before submitting a PR.
  • [X] You have added relevant documentation
  • [X] You have added relevant tests. We prefer integration tests wherever possible

Pre-Commit Instructions:

IA-PieroCV avatar Nov 26 '24 07:11 IA-PieroCV

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
robyn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 26, 2024 8:00am

vercel[bot] avatar Nov 26 '24 08:11 vercel[bot]

Hey @IA-PieroCV 👋

Is the PR still a WIP? Or is it up for review?

sansyrox avatar Nov 26 '24 19:11 sansyrox

Hey @sansyrox ! I set this PR as draft because I don't really know if the proposal of precedence is correct. I'll change it to "ready for review" in order you to review it. It's functional, but as I said, it changes the way how the authentication register the auth middlewares. Let me know any observation!

IA-PieroCV avatar Nov 26 '24 19:11 IA-PieroCV

⚠️ Only 5 files will be analyzed due to processing limits.

recurseml[bot] avatar May 27 '25 19:05 recurseml[bot]

⚠️ Only 5 files will be analyzed due to processing limits.

recurseml[bot] avatar May 27 '25 19:05 recurseml[bot]

✨ No issues found! Your code is sparkling clean! ✨

recurseml[bot] avatar May 27 '25 19:05 recurseml[bot]