LSST Data Management SQuaRE Bitly-Proxy Authenticated Sessions
Project description
# BitlyOAuth2ProxySession
This is a simple subclass of `requests.Session` which, when initialized,
or when you call its `authenticate()` method, does the magic to talk to
the Bitly OAuth2 Proxy and return a session that is authenticated for
whatever is behind it.
The use case here is a read-only service user, which does not require
two-factor authentication, that you want to be able to access resources
behind the Bitly proxy. Our _particular_ use case right now is for a
monitoring system to be able to check on web pages that require
authentication. There's one class, the imaginatively-named `Session`.
## Installation
`pip install bitly-oauth2-proxy-session`
Or check out the repository, `cd` to its root directory, and `python
setup.py install`. It requires a fairly recent `requests` (2.8.1 or
later).
## Instance Attributes
* `oauth2_username`: a string containing the username of the underlying
OAuth2 user.
* `oauth2_password`: a string containing the password of the underlying
OAuth2 user. At least for GitHub, you can't use an auth token. The
reason behind this seems to be that this is what you'd do if you were
an actual user with an actual web browser. Yes, this means 2FA isn't
currently supported.
* `authentication_base_url`: a string containing the `start` URL of your
oauth proxy. Typically, _site_`/oauth2/start`.
* `authentication_session_url`: a string containing the URL of the page
you POST to when you create a session with the underlying OAuth2
source as a web user. For Github, this is
`https://github.com/session` and that's the default.
* `authentication_postdata`: a Python dict containing the data you need
to POST to the session URL. Defaults to the right thing for Github.
## Methods
* `[get_/set_]*()`: getters and setters for the various instance
attributes. No, you can't get the password this way.
* `authenticate()`: run the authentication dance and store the magic in
the session object.
## Usage
* Acquire a `Session` object.
* For Github, create the object with `oauth2_username`,
`oauth2_password`, and `authentication_session_url`.
* For something else (untested), create the object empty, set all the
fields via the setter methods, and then run `authenticate()`. Pull
requests welcomed.
* Do sessiony things, like `get()` and `post()`.
## Bugs
* If anyone knows how I can get a session with a Github user token
rather than a password, that'd be great.
* Github is the only working use case right now.
This is a simple subclass of `requests.Session` which, when initialized,
or when you call its `authenticate()` method, does the magic to talk to
the Bitly OAuth2 Proxy and return a session that is authenticated for
whatever is behind it.
The use case here is a read-only service user, which does not require
two-factor authentication, that you want to be able to access resources
behind the Bitly proxy. Our _particular_ use case right now is for a
monitoring system to be able to check on web pages that require
authentication. There's one class, the imaginatively-named `Session`.
## Installation
`pip install bitly-oauth2-proxy-session`
Or check out the repository, `cd` to its root directory, and `python
setup.py install`. It requires a fairly recent `requests` (2.8.1 or
later).
## Instance Attributes
* `oauth2_username`: a string containing the username of the underlying
OAuth2 user.
* `oauth2_password`: a string containing the password of the underlying
OAuth2 user. At least for GitHub, you can't use an auth token. The
reason behind this seems to be that this is what you'd do if you were
an actual user with an actual web browser. Yes, this means 2FA isn't
currently supported.
* `authentication_base_url`: a string containing the `start` URL of your
oauth proxy. Typically, _site_`/oauth2/start`.
* `authentication_session_url`: a string containing the URL of the page
you POST to when you create a session with the underlying OAuth2
source as a web user. For Github, this is
`https://github.com/session` and that's the default.
* `authentication_postdata`: a Python dict containing the data you need
to POST to the session URL. Defaults to the right thing for Github.
## Methods
* `[get_/set_]*()`: getters and setters for the various instance
attributes. No, you can't get the password this way.
* `authenticate()`: run the authentication dance and store the magic in
the session object.
## Usage
* Acquire a `Session` object.
* For Github, create the object with `oauth2_username`,
`oauth2_password`, and `authentication_session_url`.
* For something else (untested), create the object empty, set all the
fields via the setter methods, and then run `authenticate()`. Pull
requests welcomed.
* Do sessiony things, like `get()` and `post()`.
## Bugs
* If anyone knows how I can get a session with a Github user token
rather than a password, that'd be great.
* Github is the only working use case right now.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bitly-oauth2-proxy-session-0.1.4.tar.gz
.
File metadata
- Download URL: bitly-oauth2-proxy-session-0.1.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8917155b34ac64b7c213efa8b8c1987b8b068bce27c851a69de8b2daa7b5ffef |
|
MD5 | a0d1c08bd8ac1631f3bc90c133ecb1f1 |
|
BLAKE2b-256 | 109d04d201c8e7e2aea75cde698b3cdc98cc5bbfa9343903c84dcfb4ed7ab84b |
File details
Details for the file bitly_oauth2_proxy_session-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: bitly_oauth2_proxy_session-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72391f5a197d465607c1edae26d1e0792031f2aac61983c09699d6cc35eb5302 |
|
MD5 | 040a6f872ada2197c16771be0c26403d |
|
BLAKE2b-256 | 072876cd4a0b0c4290a936454cff91e7f7fb330e4a63c3b89270cb73ecea7429 |