summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/resources/authentication.py
blob: 8b6b00b0873b38e57e579f3d7f2651fb97917b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def main(request, response):
    user = request.auth.username
    password = request.auth.password

    if user == b"user" and password == b"password":
        return b"Authentication done"

    realm = b"test"
    if b"realm" in request.GET:
        realm = request.GET.first(b"realm")

    return ((401, b"Unauthorized"),
            [(b"WWW-Authenticate", b'Basic realm="' + realm + b'"')],
            b"Please login with credentials 'user' and 'password'")