Code Monkey home page Code Monkey logo

requests_auth's People

Contributors

bottoy avatar colin-b avatar gabrielsroka avatar hmumm avatar rdegges avatar sdementen avatar sebastiendementen avatar stijncaerts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

requests_auth's Issues

Add a proxy auth

To send back received authentication (in another auth in theory)

Add ability to provide a refresh token

It would be helpful if there were an obvious way to provide a refresh token when creating a session. For our use case we do not support any Auth flows other than Authorization Code, but for headless execution we need to be able to persist a token somewhere and provide it.

Ideally this would be an argument to the constructors for OAuth2AuthorizationCodeFlow and the PKCE variant, but a set_refresh_token() method, or a new subclass would also be OK.

I'm happy to prepare a PR if there's a preferred approach.

Provide a pytest fixture to mock auth

For now it's a bit painful for users as they need to know what to mock and how.

Fixture should send a token containing the information as provided by the user (with default values for users that may not know the content of a token).

Fixture should also allow to test for various authentication failures sent by requests_auth so that user can test that code handles it properly.

Limit permissions of the created token cache file

It would be nice if the JsonTokenFileCache() class would create the token file cache with limited permissions, for example,

instead of:

with open(self.tokens_path, "w") as tokens_cache_file:
                json.dump(self.tokens, tokens_cache_file)

doing something like:

with open(os.open(self.tokens_path, os.O_WRONLY | os.O_CREAT, 0o600), "w") as tokens_cache_file:
                json.dump(self.tokens, tokens_cache_file)

would make the token cache file accessible for the current user only per default.

How can I mock the authentication flow in tests?

Hi @Colin-b ,

First of all, thank you for creating this library that makes it so easy to incorporate the PKCE flow! I'm using this library for a Python Windows desktop app that authenticates with Okta via the PKCE flow. I'm now trying to write integration tests but the issue is that I need to pass in test user credentials instead of using the browser for IWA. Is there a way to achieve this? I am able to call /api/v1/authn with the credentials and get a session token and am at a loss on how to use it to get the auth code bypassing browser auth.

Let me know if there is a way to do that.

Thanks

request a new token when token is too close to expire

I have an issue with a token in the cache that is expiring at time T and a request sent at time T that will use this token as not yet expired. The request fails as the token, when reaching the API backend on T+some ms is expired.
It would be useful to be able to specify some delta/interval (in seconds) that would trigger a refresh of the token if it expires after this delta.
e.g. OAuth2ClientCredentials(validity_duration=5, ...) will request a new token if `now+5>expiry´.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

add an OktaClientCredentials

in the same spirit as OktaImplicit(instance='testserver.okta-emea.com', authorization_server="my-auth-server", client_id='54239d18-c68c-4c47-8bdd-ce71ea1d50cd') but for OAuth2ClientCredentials.

Today, I need to write

OAuth2ClientCredentials(
        authorization_url="https://my-okta-instance/oauth2/my-server/v1/authorize",
        token_url="https://my-okta-instance/oauth2/my-server/v1/token",
        username="my-client-id",
        password="my-client-secret",
        scope="my-scope",
    )

while I'd like to write

OktaClientCredentials(
        instance="my-okta-instance",
        authorization_server="my-server",
        client_id="my-client-id",
        client_secret="my-client-secret",
        scope="my-scope",
    )

(the change from username/password to client_id/client_secret is also in #30

issue with timestamp calculations

Line

self._add_token(key, token, expiry.timestamp())

should be
self._add_token(key, token, expiry.replace(tzinfo=datetime.timezone.utc).timestamp())
to get correct utc timestamp.

utcnow does not set tzinfo (see https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow)
timestamp assume localtime of not tzinfo (see
see https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.