Use chargepoint identity for basic auth to be spec compliant
This commit is contained in:
parent
38d3064652
commit
6f998a3c58
|
@ -1,6 +1,5 @@
|
|||
import base64
|
||||
import binascii
|
||||
from uuid import UUID
|
||||
from starlette.authentication import (
|
||||
AuthCredentials, AuthenticationBackend, AuthenticationError, SimpleUser
|
||||
)
|
||||
|
@ -23,13 +22,9 @@ class BasicAuthBackend(AuthenticationBackend):
|
|||
raise AuthenticationError('Invalid basic auth credentials')
|
||||
|
||||
username, _, password = decoded.partition(":")
|
||||
try:
|
||||
id = UUID(username)
|
||||
except (ValueError) as exc:
|
||||
raise AuthenticationError('Invalid basic auth credentials')
|
||||
|
||||
with SessionLocal() as db:
|
||||
chargepoint = db.query(ChargePoint).filter(ChargePoint.id == id).first()
|
||||
chargepoint = db.query(ChargePoint).filter(ChargePoint.friendly_name == username).first()
|
||||
if chargepoint is None:
|
||||
raise AuthenticationError('Invalid basic auth credentials')
|
||||
if chargepoint.password != password:
|
||||
|
|
Loading…
Reference in a new issue