Skip to content

Wrong auth parameters #7

@imagekitio

Description

@imagekitio

get_authenticated_params implementation is wrong. The default value of token should be calculated before calculating the signature. If the function is not passed token then signature is calculated using an empty string but response returns a random generated token value.

    default_expire = int(dt.now().strftime("%s")) + DEFAULT_TIME_DIFF
    auth_params = {"token": token, "expire": expire, "signature": ""}

    if not private_key:
        return
    signature = hmac.new(
        key=private_key.encode(),
        msg=(token + str(expire)).encode(),
        digestmod=hashlib.sha1,
    ).hexdigest()

    auth_params["token"] = token or str(uuid.uuid4())
    auth_params["expire"] = expire or default_expire
    auth_params["signature"] = signature

    return auth_params

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions