Skip to content

Notify the application when a user completes a sign-in - #61

Merged
einari merged 4 commits into
mainfrom
feature/sign-in-notification
Jul 23, 2026
Merged

Notify the application when a user completes a sign-in#61
einari merged 4 commits into
mainfrom
feature/sign-in-notification

Conversation

@einari

@einari einari commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Adds a service-to-service back-channel that notifies the application every time a user actually signs in — when a signed-out user completes an interactive identity-provider login and a fresh session is established. This is the AuthProxy half of Cratis/Studio#877; the application (Studio) records a sign-in event so users can later be notified of new sign-ins.

Added

  • Sign-in notification back-channel: on a genuine logged-out → signed-in transition, AuthProxy POSTs { subject, identityProvider, ipAddress, location, browser, operatingSystem, userAgent } to a configured application endpoint (Cratis/Studio#877).
  • New configuration key Cratis:AuthProxy:SignIn:NotifyUrl, alongside the existing Invite:ExchangeUrl and Link:ExchangeUrl. Leave it unset to disable notifications (Cratis/Studio#877).
  • Approximate location derived from the client IP (honoring X-Forwarded-For) and any geo headers a fronting CDN/proxy adds (CF-IPCountry, X-Geo-*, X-AppEngine-*) — no heavy geo-IP dependency; when no geo headers are present only the IP travels (Cratis/Studio#877).
  • Lightweight built-in User-Agent parsing into browser and operating system, with the raw header also forwarded (Cratis/Studio#877).
  • Documentation: Documentation/configuration/sign-in.md, wired into the configuration TOC (Cratis/Studio#877).

Behavior notes

  • The notification fires only from the provider callback (OnTicketReceived), so it is scoped to real sign-ins — never on reused sessions or ordinary proxied requests. The credential-link flow short-circuits before this point, so a link is never reported as a sign-in.
  • Recording a sign-in is best-effort: any failure is logged and swallowed, and never breaks the sign-in itself.

Security

  • The endpoint is a service-to-service back-channel that carries no bearer token (there is no user-supplied token in this flow); it relies on being network-isolated from browser traffic, exactly like the invite and link exchanges. It trusts the subject AuthProxy delivers from a real provider authentication, never a client-supplied subject.
  • The client IP and derived location are personal data; the application is responsible for handling and retention.

Deployment wiring (set Cratis:AuthProxy:SignIn:NotifyUrl to the Studio Core internal endpoint) is a follow-up and is not part of this PR.

einari and others added 3 commits July 23, 2026 19:23
Add a service-to-service back-channel that posts a notification to the
application whenever a signed-out user completes an interactive
identity-provider login and a fresh session is established.

- Fire from the shared provider callback (OnTicketReceived), so the
  notification is scoped to the genuine logged-out to signed-in
  transition and never fires on reused sessions or ordinary proxied
  requests. The credential-link flow still short-circuits first, so a
  link is never reported as a sign-in.
- Derive an approximate location from the client IP (honoring
  X-Forwarded-For) and any geo headers a fronting CDN/proxy adds, with no
  heavy geo-IP dependency; parse the User-Agent into browser and OS with
  a lightweight built-in heuristic.
- Configure the endpoint under Cratis:AuthProxy:SignIn:NotifyUrl,
  alongside the invite and link exchange URLs. Recording a sign-in is
  best-effort and never breaks the sign-in itself.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover the notifier (posts subject, provider, IP, approximate location and
parsed browser; skips when unconfigured; fails without a resolvable
subject or on an endpoint error), the User-Agent parser, the client
location resolver, and the service registration.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@einari einari added the minor label Jul 23, 2026
…ication

# Conflicts:
#	Source/AuthProxy/Authentication/AuthenticationServiceCollectionExtensions.cs
@einari
einari merged commit 3d49481 into main Jul 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant