Skip to content

ValueError when using Basic Auth with malformed credentials #142

@poswald

Description

@poswald

A request to authenticate with malformed credentials causes a server error rather than a 4XX level error:

$ curl -X POST --data 'grant_type=client_credentials' -H 'Authorization: Basic asdf asdf'  http://localhost:8000/user/oauth2/token/

The problem comes from having too many spaces in the Authorization header which breaks _extract_basic_auth:

File "/Users/poswald/myproject/env/lib/python2.7/site-packages/oauth2_provider/oauth2_validators.py" in _extract_basic_auth
  37.         auth_type, auth_string = auth.split(' ')

Exception Type: ValueError at /user/oauth2/token/
Exception Value: too many values to unpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions