Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Custom AWS (requests) Authentication #716

Open
batandwa opened this issue Aug 8, 2022 · 7 comments
Open

Feature request: Custom AWS (requests) Authentication #716

batandwa opened this issue Aug 8, 2022 · 7 comments

Comments

@batandwa
Copy link

batandwa commented Aug 8, 2022

I would like create a custom hook that sets custom authentication that is compatible request module.

For context...
I thought this would be useful when I was doing AWS v4 signing using the aws_request_auth module.

@batandwa
Copy link
Author

batandwa commented Aug 8, 2022

I am willing to contribute to this...

@thp
Copy link
Owner

thp commented Aug 8, 2022

Custom authentication here means special HTTP headers sent with the request? Or something more sophisticated?

@batandwa
Copy link
Author

batandwa commented Aug 8, 2022

Whatever the request module allows in the auth parameter when executing request()

@batandwa
Copy link
Author

batandwa commented Aug 8, 2022

On the other hand...
That may lead to the request module being an irreplaceable dependency.

@thp
Copy link
Owner

thp commented Sep 17, 2022

On the other hand...
That may lead to the request module being an irreplaceable dependency.

That's fine, it is already a required dependency.

Whatever the request module allows in the auth parameter when executing request()

The docs say:

auth – (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.

So I guess this means you get a tuple like (username, password) passed there and requests takes care of creating the right header. Should be easy to allow for this. However, for "custom" authentication, you can anyway just set a HTTP header. Granted, for Basic auth, username/password is convenient, and for Digest auth it's essential.

@thp
Copy link
Owner

thp commented Sep 17, 2022

..and i read your request again -- in this case, you probably would like to have a way of adding all the AWS settings and then pass the AWSRequestsAuth() object to the auth, so just configuring username/password in the YAML is not enough.

@thp
Copy link
Owner

thp commented Sep 17, 2022

One way to do it would be to subclass jobs.UrlJob as done in share/urlwatch/examples/hooks.py.example:

class CustomLoginJob(jobs.UrlJob):
    """Custom login for my webpage"""

    __kind__ = 'aws-login'
    __required__ = ('aws_access_key', 'aws_secret_access_key', ...)

    def retrieve(self, job_state):
        ... # TODO: Make request, return response, use self.aws_access_key, etc...

@thp thp changed the title Feature request: Custom Authentication Feature request: Custom AWS (requests) Authentication Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants