Skip to main content

A solid-OIDC client

Project description

Solid OIDC Client

A client to use Solid-OIDC authentication.

Status

This is in beta: use with care. Expect bugs and breaking changes even with minor version updates.

Currently following features are missing:

  • refreshing expired tokens
  • persistent client id and client secret

Contributing

Contributions are welcome. These could be additional features, bug fixes, automated testing, better documentation or any other contribution.

Example app

Here is a simple example that authenticates users with this library and makes authenticated requests in the python backend: https://github.com/Otto-AA/solid-flask

Installation

pip install solid_oidc_client

Usage

Following code guides you through the authentication process:

from solid_oidc_client import SolidOidcClient, SolidAuthSession, MemStore

# create a client instance
solid_oidc_client = SolidOidcClient(storage=MemStore())
OAUTH_CALLBACK_URI = '/oauth/callback'

# register this application with the issuer (client_id and client_secret are currently only stored in memory, regardless of the previous storage)
# the redirect url in this case is /oauth/callback
solid_oidc_client.register_client('https://login.inrupt.com/', [OAUTH_CALLBACK_URI])

# initiate a login by redirecting the user to this url
# store the path you want to redirect the user after the login ('/')
login_url = solid_oidc_client.create_login_uri('/', OAUTH_CALLBACK_URI)

# wait for the user to login with their identity provider
# listen on /oauth/callback
# then get code and state from the query params
code = flask.request.args['code']
state = flask.request.args['state']

# and use them to get an authentication session
# internally this will store an access token and key for dpop
session = solid_oidc_client.finish_login(
    code=code,
    state=state,
    callback_uri=OAUTH_CALLBACK_URI,
)

# use this session to make authenticated requests
private_url = 'https://pod.example.org/private/secret.txt'
auth_headers = session.get_auth_headers(private_url, 'GET')
res = requests.get(url=tested_url, headers=auth_headers)
print(res.text)


# optionally serialize and deserialize the sessions to store them as a string client/server side
flask.session['auth'] = session.serialize()
session = SolidAuthSession.deserialize(flask.session['auth'])

Acknowledgments

This is based on solid-flask by Rai.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solid_oidc_client-0.0.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

solid_oidc_client-0.0.4-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file solid_oidc_client-0.0.4.tar.gz.

File metadata

  • Download URL: solid_oidc_client-0.0.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for solid_oidc_client-0.0.4.tar.gz
Algorithm Hash digest
SHA256 1e7143a5d2f7e4623b736d3b414848574163815b4e30b6c62896c8f63dc1020b
MD5 3a341b214db5170785ec85eed1e43127
BLAKE2b-256 01bd4c7693fce0ecd93f3e7685e688b4d91b3abd83fe6fcb795ab0eca146b424

See more details on using hashes here.

File details

Details for the file solid_oidc_client-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for solid_oidc_client-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0ade3ae58c46f03b1ed1a093cb41412894bd49eaef7da0fcd5de18c3f3d50e63
MD5 b404af1fe013746501f4b659b9e910b6
BLAKE2b-256 f72c69eaaf98ca17fbaeba4e7c16dd1466211c5a0a01fd82be12b5032bb442f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page