- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 310
 
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
I tried to see if this was mentioned anywhere but I didn't see any currently open issues regarding this.
Issue
Adding a trailing slash to the endpoint (i.e. /auth/ vs /auth) in the request will bypass the authentication step.
Expected
I would expect that the request would fail to authorize like the request with no slash.
I don't know the code enough to find what is causing this but I'm still searching and I'll update here if I find it.
Steps to Reproduce
Code
This sample is taken straight from the docs but I found this while working on my own API.
from robyn import Request, Robyn
from robyn.authentication import AuthenticationHandler, BearerGetter, Identity
app = Robyn(__file__)
class BasicAuthHandler(AuthenticationHandler):
    def authenticate(self, request: Request) -> Identity | None:
        token = self.token_getter.get_token(request)
        if token == "valid":
            return Identity(claims={})
        return None
app.configure_authentication(BasicAuthHandler(token_getter=BearerGetter()))
@app.get("/auth", auth_required=True)
async def auth(request: Request):
    # This route method will only be executed if the user is authenticated
    # Otherwise, a 401 response will be returned
    return "Hello, world"
if __name__ == "__main__":
    app.start(host="0.0.0.0", port=8080)
Tests
$ curl -X GET 0.0.0.0:8080/auth
Unauthorized
$  curl -X GET 0.0.0.0:8080/auth/
Hello, world
>>> requests.get("http://0.0.0.0:8080/auth").text
'Unauthorized'
>>> requests.get("http://0.0.0.0:8080/auth/").text
'Hello, world'
Your operating system
Linux
Your Python version (python --version)
Other (specify below)
Your Robyn version
latest
Additional Info
Python version: 3.10.18
Robyn version: 0.72.1
The dropdown has Python 3.1 where I'd expect 3.10.
sansyrox and thePromgerthePromger
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working