Skip to content

🐛 OAuth2 sign-in flow, profile auto-creation, and E2E tests#10

Merged
turtton merged 17 commits into
mainfrom
fix/signin
May 11, 2026
Merged

🐛 OAuth2 sign-in flow, profile auto-creation, and E2E tests#10
turtton merged 17 commits into
mainfrom
fix/signin

Conversation

@turtton

@turtton turtton commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

  • OAuth2ログインフロー(Ory Hydra + Kratos)の修正と安定化
  • Account作成時にProfileを自動生成する機能を追加
  • axum 0.8 / tower-http 0.6 へのアップグレード
  • Keto OPL (Ory Permission Language) への権限モデル移行
  • OpenAPIスペック駆動のスモークテスト追加
  • OAuth2ログイン→Account作成→Profile自動生成を検証するE2Eテスト追加 (server/tests/e2e_basic_flow.rs)

Changes

Bug Fixes

  • :bug: HTTP 302 を OAuth2 login/consent エンドポイントから正しく返すように修正
  • :bug: OffsetDateTime を ISO 8601 (RFC3339) フォーマットにシリアライズするよう修正
  • :bug: CommandProcessor で Account ReadModel 作成を同期化し、find_or_create パターンの競合を防止
  • :bug: Keto v0.12 の HTTP 403 レスポンス処理を修正

Features

  • :sparkles: Account 作成時に Profile を自動生成
  • :sparkles: Hydra id_token に email クレームを含める

Refactoring

  • :recycle: Keto 権限モデルを OPL に移行
  • :recycle: パスパラメータ名を OpenAPI 一貫性のために統一
  • :recycle: ルートスモークテストを OpenAPI スペック駆動に変更
  • :arrow_up: axum 0.8, tower-http 0.6 へアップグレード

Testing

  • :white_check_mark: E2E テスト追加: OAuth2 login → Account 作成 → Profile 非同期プロジェクション検証
    • justfilejust e2e / just e2e-down コマンド追加
    • reqwest によるブラックボックス HTTP テスト
    • Ory Hydra/Kratos との完全な OAuth2 フロー実行

Running E2E Tests

# 必要サービスの起動を含め全自動で実行
just e2e

# サービスの後片付け
just e2e-down

turtton added 12 commits March 31, 2026 15:04
OAuth2 endpoints previously returned redirect URLs as JSON 200 responses.
Hydra standard OAuth2 flow expects browser redirects via HTTP 302 with
Location headers.
Pass email from Kratos identity traits through login context to consent
handler. Only include email claim in id_token when "email" scope is
granted, preventing unintended PII disclosure.
Account creation now automatically creates a Profile with display_name
set to the account name, eliminating the need for a separate
POST /accounts/{account_id}/profile endpoint.

- Add ProfileCommandProcessor dependency to CreateAccountUseCase
- Add synchronous ReadModel write to ProfileCommandProcessor::create
- Remove POST profile endpoint, CreateProfileUseCase, and related DTOs
- Regenerate openapi.json, update CLAUDE.md
Replace hardcoded relation-based permission checks with OPL permits.
Namespace names updated to match OPL class names (Account, Instance).
Permission hierarchy (owners->view/edit/sign/deactivate, etc.) is now
defined in namespaces.ts and resolved by Keto, simplifying Rust code
to single-request permission checks.
@turtton turtton changed the title fix: OAuth2 sign-in flow, profile auto-creation, and E2E tests 🐛 OAuth2 sign-in flow, profile auto-creation, and E2E tests May 11, 2026
@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.86822% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.08%. Comparing base (82e3a65) to head (b22a4a5).

Files with missing lines Patch % Lines
driver/src/keto.rs 0.00% 27 Missing ⚠️
server/src/route/account.rs 31.03% 20 Missing ⚠️
adapter/src/processor/account.rs 0.00% 14 Missing ⚠️
application/src/service/account.rs 0.00% 14 Missing ⚠️
kernel/src/permission.rs 0.00% 12 Missing ⚠️
server/src/route/oauth2.rs 90.78% 7 Missing ⚠️
adapter/src/processor/profile.rs 0.00% 5 Missing ⚠️
application/src/permission.rs 0.00% 5 Missing ⚠️
server/src/route.rs 99.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
+ Coverage   63.73%   66.08%   +2.34%     
==========================================
  Files          98       99       +1     
  Lines        9655     9775     +120     
==========================================
+ Hits         6154     6460     +306     
+ Misses       3501     3315     -186     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

turtton added 5 commits May 11, 2026 22:27
cargo binstall downloads prebuilt binaries and does not accept
--no-default-features/--features flags.
- Add cargo build -p server step before running E2E tests so that
  cargo run inside the test starts the prebuilt binary immediately.
- Extend wait_until_ready timeout from 30s to 60s as a safety margin.
- Split justfile into composable recipes (up, wait-services, migrate, e2e-test, e2e)
- Workflow now invokes 'just e2e' and 'just down' instead of inlining bash
- Keeps local and CI E2E flows consistent
@turtton
turtton merged commit bf98a80 into main May 11, 2026
14 checks passed
@turtton
turtton deleted the fix/signin branch May 11, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant