Optional authentication
See original GitHub issueIs this already possible? Is it bad practice? If not, how difficult do you think it would it be to implement?
If you can point me in the right direction then I can try to create a PR
E.g. something along the lines of
@router.get("/secure", dependencies=[Depends(auth.implicit_scheme)])
def get_secure(
user: Optional[Auth0User] = None
):
return {"message": f"{user}"}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Optional Authentication
Optional Authentication. Unlike a situation where you require authentication, you may come across certain scenarios where you can have a user logged in, ......
Read more >Optional Authentication for API?
Hi! Any tips for building an Optional Authentication Middleware for an API? I'm using Passport with Personal Tokens. I want to do something...
Read more >Support Optional Authentication Mechanisms - TechDocs
The following tasks that are related to optional authentication support are described: Create a Custom Identity Provider.
Read more >Required vs. Disabled vs. Optional Authentication
Required Authentication. The richest form of data collection · The double "opt-in" ensures your truest fans engage with you ; Disabled ...
Read more >javascript - Optional Authentication in nestjs
There is no built-in decorator but you can easily create one yourself. See the example from the docs: import { createParamDecorator } from ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is already supported, although you have to be extra careful.
By default
auto_error = True
so you will set it to false. In case of a failed authentication / authorization,auth.get_user
returns None instead of raising Auth0UnauthenticatedException that triggers the typical 401 response.Note that you can have multiple Auth0 objects in the same app, so if you have some endpoints that always need authentication (no public mixup), I recommend using the regular
auth
and leavedangerous_auth
only for those public endpoints.Released fix as 0.2.1