Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Daptin Two-Instance OAuth Demo

This demo runs two Daptin instances:

  • Provider: http://localhost:6337
  • Consumer: http://localhost:6336

The consumer uses the provider through the standard OAuth 2.0 authorization-code flow. There is no helper web server in this demo.

Run

docker compose up -d
python3 scripts/setup.py

The compose file uses daptin/daptin:latest by default. To test another locally built or published image:

DAPTIN_IMAGE=daptin/daptin:latest docker compose up -d

Browser Flow

After setup, start the login flow with:

scripts/start-login.sh

Open the printed URL if the script does not open it automatically:

http://localhost:6336/oauth/login/<authenticator>

Expected flow:

  1. Consumer /oauth/login/<authenticator> creates OAuth state and redirects to provider /oauth/authorize.
  2. Provider sends the browser to native Daptin /auth/signin if there is no provider session.
  3. Sign in with the provider demo account printed by scripts/setup.py.
  4. Provider redirects to consumer /oauth/response?authenticator=<authenticator>&code=...&state=....
  5. Consumer exchanges the code at provider /oauth/token, fetches profile from provider /oauth/userinfo, creates or finds the user, sets the normal Daptin HttpOnly token cookie, and redirects to /.

If the dashboard frontend later routes to /sign-in, check the network response for /oauth/response: the OAuth callback is complete when that response is 302 and includes Set-Cookie: token=....

Dashboard support for showing a native "Sign in with OAuth provider" action is tracked separately in artpar/dashboard3#2.

Callback Contract

The provider app must register the exact consumer callback URL:

http://localhost:6336/oauth/response?authenticator=<authenticator>

The consumer oauth_connect.redirect_uri stores the base callback:

http://localhost:6336/oauth/response

Daptin appends authenticator=<oauth_connect.name> while building the authorization URL.

The consumer does not know or care that the provider is Daptin. It uses the configured OAuth URLs:

  • auth_url: browser-facing provider /oauth/authorize
  • token_url: consumer-to-provider /oauth/token
  • profile_url: consumer-to-provider /oauth/userinfo

Reset

docker compose down -v
rm -f .env.local

About

Two-instance Daptin OAuth provider and consumer demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages