Skip to content

delhi09/auth_infra_prototype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auth_infra_prototype

起動

docker compose up -d

ユーザー作成

docker compose exec billing_infra python manage.py createsuperuser

マイグレーション

docker compose exec billing_infra python manage.py migrate

ユーザー認証

エンドポイント一覧の確認

http://localhost:18080/realms/master/.well-known/openid-configuration にブラウザでアクセス

認証リクエスト

  • http://localhost:18080/realms/master/protocol/openid-connect/auth?response_type=code&scope=openid&client_id={client_id}&state=abcdefgh&redirect_uri=http://localhost:18000/callback/&nonce=hijklmno にKeycloakログイン済みのブラウザでアクセスする
  • client_idはKeycloakの管理画面から確認する
  • 事前にKeycloakのClientのredirect_urihttp://localhost:18000/callback/を登録しておく必要あり

トークンリクエスト

  • 認証リクエストのリダイレクト先URLのクエリーストリングからcodeをコピーして控える
  • client_idclient_secretはKeycloakの管理画面から確認する
curl -X POST "http://localhost:18080/realms/master/protocol/openid-connect/token" -d "redirect_uri=http://localhost:18000/callback/" -d "grant_type=authorization_code" -d "code={code}" -d "client_id={client_id}" -d "client_secret={client_secret}"| jq -r ".access_token"

→ アクセストークンを取得できる

ユーザーインフォリクエスト

curl -X GET "http://localhost:18000/api/userinfo/" -H "Authorization: {アクセストークン}"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published