mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 01:08:28 +02:00
Graceful oauth server shutdown
This commit is contained in:
@@ -184,6 +184,18 @@ export function buildHostedCallbackRedirectUri(localPort: number, localPath: str
|
|||||||
return `${HOSTED_CALLBACK_URL}?redirect_to=${encodeURIComponent(localRedirectUri)}`;
|
return `${HOSTED_CALLBACK_URL}?redirect_to=${encodeURIComponent(localRedirectUri)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the active callback server if one is running.
|
||||||
|
* Called during plugin dispose to ensure the server is cleaned up before the process exits.
|
||||||
|
*/
|
||||||
|
export function stopActiveServer(): void {
|
||||||
|
if (activeServer) {
|
||||||
|
console.log('[oauth2] Stopping active callback server during dispose');
|
||||||
|
activeServer.stop();
|
||||||
|
activeServer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an authorization URL in the system browser, start a local callback server,
|
* Open an authorization URL in the system browser, start a local callback server,
|
||||||
* and wait for the OAuth provider to redirect back.
|
* and wait for the OAuth provider to redirect back.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type {
|
|||||||
JsonPrimitive,
|
JsonPrimitive,
|
||||||
PluginDefinition,
|
PluginDefinition,
|
||||||
} from '@yaakapp/api';
|
} from '@yaakapp/api';
|
||||||
import { DEFAULT_LOCALHOST_PORT, HOSTED_CALLBACK_URL } from './callbackServer';
|
import { DEFAULT_LOCALHOST_PORT, HOSTED_CALLBACK_URL, stopActiveServer } from './callbackServer';
|
||||||
import {
|
import {
|
||||||
type CallbackType,
|
type CallbackType,
|
||||||
DEFAULT_PKCE_METHOD,
|
DEFAULT_PKCE_METHOD,
|
||||||
@@ -78,6 +78,9 @@ const accessTokenUrls = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const plugin: PluginDefinition = {
|
export const plugin: PluginDefinition = {
|
||||||
|
dispose() {
|
||||||
|
stopActiveServer();
|
||||||
|
},
|
||||||
authentication: {
|
authentication: {
|
||||||
name: 'oauth2',
|
name: 'oauth2',
|
||||||
label: 'OAuth 2.0',
|
label: 'OAuth 2.0',
|
||||||
|
|||||||
Reference in New Issue
Block a user