Pireon OAuth clients allow a single grant type. With one PIREON_CLIENT_ID of type password, email + password worked but "Sign in with Pireon" failed with `unauthorized_client`. - PIREON_CLIENT_ID/SECRET: authorization_code client (Sign in with Pireon, Swagger UI). New PIREON_PASSWORD_CLIENT_ID/SECRET: password client, falling back to the former so existing setups keep working. - Refresh tries both clients: a refresh token only works with its issuer. - PIREON_PASSWORD_GRANT=false now also rejects password grants in the API (before it only hid the form). - /api/auth/config returns clientId: null when there is no authorization_code client, and the web hides "Sign in with Pireon". - docker-compose passes the new variables; docs 05/07, .env.example, openapi.json; unit tests for the client selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
910 B
TypeScript
32 lines
910 B
TypeScript
/** How a client proves who it is to get tokens from the identity server. */
|
|
export type TokenGrant =
|
|
| {
|
|
type: 'authorization_code';
|
|
code: string;
|
|
codeVerifier: string;
|
|
redirectUri: string;
|
|
}
|
|
| { type: 'password'; username: string; password: string }
|
|
| { type: 'refresh_token'; refreshToken: string };
|
|
|
|
export interface TokenSet {
|
|
accessToken: string;
|
|
refreshToken: string | null;
|
|
/** Seconds until the access token expires. */
|
|
expiresIn: number;
|
|
tokenType: string;
|
|
}
|
|
|
|
/** How a browser can sign in. */
|
|
export interface AuthorizationConfig {
|
|
authorizeUrl: string;
|
|
/**
|
|
* Client for Authorization Code + PKCE ("Sign in with Pireon"). Null when
|
|
* only email + password is configured: Pireon clients allow a single grant.
|
|
*/
|
|
clientId: string | null;
|
|
scopes: string[];
|
|
/** Whether email + password sign-in is available. */
|
|
passwordGrant: boolean;
|
|
}
|