Skip to content

Commit 967fcba

Browse files
committed
Adding documentation on how to use OIDC
1 parent 96cd9db commit 967fcba

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

docs/source/configuration.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,85 @@ See the documentation on ``LDAPAuthenticator`` for more details.
294294

295295
authenticators.LDAPAuthenticator
296296

297+
OIDC Authenticator
298+
++++++++++++++++++
299+
300+
``OIDCAuthenticator`` integrates the server with third-party OpenID Connect providers
301+
such as Google, Microsoft Entra ID, ORCID and others. The server does not process user
302+
passwords directly: authentication is delegated to the provider and the server validates
303+
the returned OIDC token.
304+
305+
General setup steps:
306+
307+
#. Register an application with the OIDC provider.
308+
#. Configure redirect URIs for the provider application. For provider name ``entra`` and
309+
host ``https://your-server.example`` the redirect URIs are:
310+
311+
- ``https://your-server.example/api/auth/provider/entra/code``
312+
- ``https://your-server.example/api/auth/provider/entra/device_code``
313+
314+
#. Store the client secret in environment variable and reference it in config.
315+
#. Use provider's ``.well-known/openid-configuration`` URL.
316+
317+
Typical ``well_known_uri`` values:
318+
319+
- Google: ``https://accounts.google.com/.well-known/openid-configuration``
320+
- Microsoft Entra ID: ``https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration``
321+
- ORCID: ``https://orcid.org/.well-known/openid-configuration``
322+
323+
Example configuration (Microsoft Entra ID)::
324+
325+
authentication:
326+
providers:
327+
- provider: entra
328+
authenticator: bluesky_httpserver.authenticators:OIDCAuthenticator
329+
args:
330+
audience: 00000000-0000-0000-0000-000000000000
331+
client_id: 00000000-0000-0000-0000-000000000000
332+
client_secret: ${BSKY_ENTRA_SECRET}
333+
well_known_uri: https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration
334+
confirmation_message: "You have logged in successfully."
335+
api_access:
336+
policy: bluesky_httpserver.authorization:DictionaryAPIAccessControl
337+
args:
338+
users:
339+
<login-name>:
340+
roles:
341+
- admin
342+
- expert
343+
344+
Example configuration (Google)::
345+
346+
authentication:
347+
providers:
348+
- provider: google
349+
authenticator: bluesky_httpserver.authenticators:OIDCAuthenticator
350+
args:
351+
audience: <google-client-id>
352+
client_id: <google-client-id>
353+
client_secret: ${BSKY_GOOGLE_SECRET}
354+
well_known_uri: https://accounts.google.com/.well-known/openid-configuration
355+
api_access:
356+
policy: bluesky_httpserver.authorization:DictionaryAPIAccessControl
357+
args:
358+
users:
359+
<login-name>:
360+
roles: user
361+
362+
.. note::
363+
364+
The name used in ``api_access/args/users`` must match the identity string produced by
365+
the authenticator for your provider configuration. Verify with ``/api/auth/whoami`` after
366+
successful login.
367+
368+
See the documentation on ``OIDCAuthenticator`` for parameter details.
369+
370+
.. autosummary::
371+
:nosignatures:
372+
:toctree: generated
373+
374+
authenticators.OIDCAuthenticator
375+
297376

298377
Expiration Time for Tokens and Sessions
299378
+++++++++++++++++++++++++++++++++++++++

docs/source/usage.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,49 @@ Then users ``bob``, ``alice`` and ``tom`` can log into the server as ::
154154

155155
If authentication is successful, then the server returns access and refresh tokens.
156156

157+
Logging in with OIDC Providers (Google, Entra, ORCID, ...)
158+
-----------------------------------------------------------
159+
160+
For providers configured with ``OIDCAuthenticator``, use provider-specific endpoints
161+
under ``/api/auth/provider/<provider-name>/...``.
162+
163+
Browser-first flow
164+
++++++++++++++++++
165+
166+
If you are already in a browser context, open:
167+
168+
``<hostname>/api/auth/provider/<provider-name>/authorize``
169+
170+
This redirects to the OIDC provider login page and then back to the server callback.
171+
172+
CLI/device flow
173+
+++++++++++++++
174+
175+
For terminal clients, start with ``POST /api/auth/provider/<provider-name>/authorize``.
176+
The response includes:
177+
178+
- ``authorization_uri``: open this URL in a browser
179+
- ``verification_uri``: polling endpoint for the terminal client
180+
- ``device_code`` and ``interval``: values for polling
181+
182+
Example using ``httpie`` (provider ``entra``)::
183+
184+
http POST http://localhost:60610/api/auth/provider/entra/authorize
185+
186+
After opening ``authorization_uri`` in a browser and completing provider login,
187+
poll ``verification_uri`` using ``device_code`` until tokens are issued::
188+
189+
http POST http://localhost:60610/api/auth/provider/entra/token \
190+
device_code='<device_code_from_authorize_response>'
191+
192+
When authorization is still pending, the endpoint returns ``authorization_pending``.
193+
When complete, it returns access and refresh tokens.
194+
195+
.. note::
196+
197+
In common same-device flows the callback can complete automatically without manually
198+
typing the user code. Manual code entry remains available as a fallback path.
199+
157200
Generating API Keys
158201
-------------------
159202

0 commit comments

Comments
 (0)