Skip to content

User agent header evaluation order corner case #70

@naglis

Description

@naglis

Hi,

while trying to add credentials for Odoo, I have stumbled upon a weird corner case with user agent headers.

Upon successful login, Odoo redirects the user to either a user given URL (unvalidated redirect :/) or base back-office URL, but the redirect method is different depending on the user agent.

I am using the redirect as an indicator for login success, and I need a constant user agent in order to get consistent results.

It turns out, changeme by default uses a random user agent from a predefined list.

I have tried setting the headers in auth block, but it appears that the user agent is overwritten with the one selected by changeme afterwards, so, no luck :/

It works great if I pass my user agent via CLI parameters, however, this is not an optimal solution.

I have tried to change the order in which the headers are calculated, so that custom headers from the credentials file are applied afterwards, eg.:

self.headers.update(self.config.useragent)
headers = self.cred['auth'].get('headers', dict())
if headers:
    for h in headers:
        self.headers.update(h)

and it seems to work great. However, I was not sure if the previous header evaluation order was intentional or not. Please let me know if you think the solution is suitable, and I'll gladly make a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions