question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extend existing Authentication methods to provide Authorization features

See original GitHub issue

Is your feature request related to a problem? Please describe. Currently the authorization methods withAuthUserTokenSSR and withAuthUserSSR allow us to validate if a request for page is Authenticated or not. We require that users are not only Authenticated but that the user also has the Custom Claim admin.

Describe the solution you’d like and how you’d implement it The existing withAuthUserTokenSSR and withAuthUserSSR methods will be extended to take 2 optional additional parameters; which will be used to verify if the Authenticated users is Authorized to access the page; and if not redirect them to an appropriate access denied page (provided by the developer).

  • whenAuthed?: AuthAction.RENDER | AuthAction.REDIRECT_TO_APP
  • whenUnauthed?: AuthAction.RENDER | AuthAction.REDIRECT_TO_LOGIN
  • appPageURL?: PageURL
  • authPageURL?: PageURL
  • validator? (user: AuthUser) => boolean
  • accessDeniedPageURL?: PageUrl

The existing method will be extended to accept the 2 emboldened new parameters (validator and accessDeniedPageURL). The method will then, once we have verified the authUser with existing code, run the validator function (if it is provided). If the validator function returns false we should then redirect the users to the accessDeniedPageURL.

Is this a breaking change? No, the additional options would be optional and so an opt in approach to upgrading the interface.

Describe alternatives you’ve considered The alternative we are currentyl using is handling this in our own code. While this is okay, it would be (I think) a feature that would be nice to push up to the framework.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lazlothemonkeycommented, Aug 29, 2021

I also would like to have this feature, for instance to only grant access to a page if the emailVerified key on the User object is true.

1reaction
kmjennisoncommented, Aug 27, 2021

Auth0’s Next.js API could provide some guidance: https://github.com/auth0/nextjs-auth0#api-reference

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use these 6 user authentication types to secure networks
Compare six user authentication types that help companies secure networks, as well protocols designed to secure the transfer of authentication data.
Read more >
Authorization Extension - Auth0
With the Authorization Extension, you can store authorization data like groups, roles, or permissions in the outgoing token issued by Auth0. Your application ......
Read more >
User Authentication Methods & Technologies to Prevent Breach
Authentication is the process of identifying users that request access to a system, network, or device. Access control often determines user identity according ......
Read more >
Authentication methods and features - Azure Active Directory
Learn about the different authentication methods and features available in Azure Active Directory to help improve and secure sign-in events.
Read more >
Authentication, Authorization, and Accounting Configuration ...
How to Configure AAA Authentication Methods. Note. AAA features are not available until you enable AAA globally using the aaa ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found