@mcp-abap-adt/auth-broker 0.2.14 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +20 -11
- package/bin/mcp-auth.ts +58 -43
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,24 @@ Thank you to all contributors! See [CONTRIBUTORS.md](CONTRIBUTORS.md) for the co
|
|
|
11
11
|
|
|
12
12
|
## [Unreleased]
|
|
13
13
|
|
|
14
|
+
## [0.2.16] - 2025-12-31
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- **CLI**: Changed default authentication flow from `client_credentials` to `authorization_code`
|
|
18
|
+
- Both ABAP and XSUAA now use `authorization_code` by default (browser-based OAuth2)
|
|
19
|
+
- Default browser is `auto` (tries to open browser, falls back to showing URL)
|
|
20
|
+
- Added `--credential` flag for `client_credentials` flow (special cases)
|
|
21
|
+
- `--browser none` shows URL in console and waits for callback (no browser opened)
|
|
22
|
+
- **CLI**: Updated help text and examples to reflect new defaults
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- **CLI**: Fixed process hanging after successful token retrieval by adding explicit `process.exit(0)`
|
|
26
|
+
|
|
27
|
+
## [0.2.15] - 2025-12-30
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- **CLI**: Remove duplicate `authConfig` declaration in `mcp-auth.ts` that caused esbuild/tsx to fail with "symbol already declared" error
|
|
31
|
+
|
|
14
32
|
## [0.2.14] - 2025-12-26
|
|
15
33
|
|
|
16
34
|
### Added
|
package/README.md
CHANGED
|
@@ -644,25 +644,34 @@ const btpBrokerFull = new AuthBroker({
|
|
|
644
644
|
Generate or refresh `.env`/JSON output using AuthBroker + stores:
|
|
645
645
|
|
|
646
646
|
```bash
|
|
647
|
-
mcp-auth --service-key <path> --output <path> [--env <path>] [--type abap|xsuaa] [--browser system|chrome|edge|firefox
|
|
647
|
+
mcp-auth --service-key <path> --output <path> [--env <path>] [--type abap|xsuaa] [--credential] [--browser auto|none|system|chrome|edge|firefox] [--format json|env]
|
|
648
648
|
```
|
|
649
649
|
|
|
650
|
-
**
|
|
651
|
-
-
|
|
652
|
-
-
|
|
653
|
-
|
|
654
|
-
|
|
650
|
+
**Authentication Flow:**
|
|
651
|
+
- Default: `authorization_code` (browser-based OAuth2)
|
|
652
|
+
- `--credential`: `client_credentials` (clientId/clientSecret, no browser)
|
|
653
|
+
|
|
654
|
+
**Browser Options (for authorization_code):**
|
|
655
|
+
- `auto` (default): Try to open browser, fallback to showing URL
|
|
656
|
+
- `none`: Show URL in console and wait for callback (no browser)
|
|
657
|
+
- `system/chrome/edge/firefox`: Open specific browser
|
|
655
658
|
|
|
656
659
|
**Examples:**
|
|
657
660
|
```bash
|
|
658
|
-
#
|
|
659
|
-
mcp-auth --
|
|
661
|
+
# ABAP: authorization_code (default, opens browser)
|
|
662
|
+
mcp-auth --service-key ./abap.json --output ./abap.env --type abap
|
|
660
663
|
|
|
661
|
-
# ABAP:
|
|
662
|
-
mcp-auth --service-key ./abap.json --output ./abap.env --type abap --browser
|
|
664
|
+
# ABAP: authorization_code (show URL in console, no browser)
|
|
665
|
+
mcp-auth --service-key ./abap.json --output ./abap.env --type abap --browser none
|
|
663
666
|
|
|
664
|
-
# XSUAA:
|
|
667
|
+
# XSUAA: authorization_code (default)
|
|
665
668
|
mcp-auth --service-key ./mcp.json --output ./mcp.env --type xsuaa
|
|
669
|
+
|
|
670
|
+
# XSUAA: client_credentials (special cases)
|
|
671
|
+
mcp-auth --service-key ./mcp.json --output ./mcp.env --type xsuaa --credential
|
|
672
|
+
|
|
673
|
+
# Using existing .env for refresh token
|
|
674
|
+
mcp-auth --env ./mcp.env --service-key ./mcp.json --output ./mcp.env --type xsuaa
|
|
666
675
|
```
|
|
667
676
|
|
|
668
677
|
### Utility Script
|
package/bin/mcp-auth.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
/**
|
|
3
3
|
* MCP Auth - Get tokens and generate .env files from service keys
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* Usage:
|
|
6
|
-
* mcp-auth --service-key <path> --output <path> [--env <path>] [--type abap|xsuaa] [--browser none|chrome|edge|firefox|system] [--format json|env]
|
|
7
|
-
*
|
|
6
|
+
* mcp-auth --service-key <path> --output <path> [--env <path>] [--type abap|xsuaa] [--credential] [--browser auto|none|chrome|edge|firefox|system] [--format json|env]
|
|
7
|
+
*
|
|
8
8
|
* Examples:
|
|
9
|
-
* # Generate .env file (default)
|
|
9
|
+
* # Generate .env file with authorization_code (default)
|
|
10
|
+
* mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa
|
|
11
|
+
*
|
|
12
|
+
* # With authorization_code, show URL in console (no browser)
|
|
10
13
|
* mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --browser none
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* # With client_credentials (special cases)
|
|
16
|
+
* mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --credential
|
|
17
|
+
*
|
|
16
18
|
* # Generate .env file for ABAP
|
|
17
|
-
* mcp-auth --service-key ./abap-key.json --output ./abap.env --type abap
|
|
19
|
+
* mcp-auth --service-key ./abap-key.json --output ./abap.env --type abap
|
|
18
20
|
*/
|
|
19
21
|
|
|
20
22
|
import * as path from 'path';
|
|
@@ -44,7 +46,8 @@ interface McpAuthOptions {
|
|
|
44
46
|
envFilePath?: string;
|
|
45
47
|
outputFile: string;
|
|
46
48
|
authType: 'abap' | 'xsuaa';
|
|
47
|
-
browser
|
|
49
|
+
browser: string; // Browser for authorization_code flow (default: 'auto')
|
|
50
|
+
credential: boolean; // Use client_credentials instead of authorization_code
|
|
48
51
|
format: 'json' | 'env';
|
|
49
52
|
serviceUrl?: string;
|
|
50
53
|
redirectPort?: number; // Port for OAuth redirect URI (default: 3001)
|
|
@@ -75,13 +78,13 @@ function showHelp(): void {
|
|
|
75
78
|
console.log('');
|
|
76
79
|
console.log('Optional Options:');
|
|
77
80
|
console.log(' --type <type> Auth type: abap or xsuaa (default: abap)');
|
|
78
|
-
console.log(' --
|
|
79
|
-
console.log('
|
|
81
|
+
console.log(' --credential Use client_credentials flow (clientId/clientSecret, no browser)');
|
|
82
|
+
console.log(' By default uses authorization_code flow');
|
|
83
|
+
console.log(' --browser <browser> Browser for authorization_code flow (default: auto):');
|
|
80
84
|
console.log(' - auto: Try to open browser, fallback to showing URL (like cf login)');
|
|
85
|
+
console.log(' - none/headless: Show URL in console and wait for callback');
|
|
81
86
|
console.log(' - system/chrome/edge/firefox: Open specific browser');
|
|
82
|
-
console.log('
|
|
83
|
-
console.log(' If not specified: uses client_credentials (clientId/clientSecret)');
|
|
84
|
-
console.log(' --format <format> Output format: json or env (default: env)');
|
|
87
|
+
console.log(' --format <format> Output format: json or env (default: env)');
|
|
85
88
|
console.log(' --service-url <url> Service URL (SAP URL for ABAP, MCP URL for XSUAA). For XSUAA, optional.');
|
|
86
89
|
console.log(' --redirect-port <port> Port for OAuth redirect URI (default: 3001). Must match XSUAA redirect-uris config.');
|
|
87
90
|
console.log('');
|
|
@@ -89,37 +92,39 @@ function showHelp(): void {
|
|
|
89
92
|
console.log(' --help, -h Show this help message');
|
|
90
93
|
console.log('');
|
|
91
94
|
console.log('Examples:');
|
|
92
|
-
console.log(' # XSUAA with
|
|
95
|
+
console.log(' # XSUAA with authorization_code (default, opens browser)');
|
|
93
96
|
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa');
|
|
94
97
|
console.log('');
|
|
98
|
+
console.log(' # XSUAA with authorization_code (show URL in console, no browser)');
|
|
99
|
+
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --browser none');
|
|
100
|
+
console.log('');
|
|
95
101
|
console.log(' # XSUAA using existing .env refresh token, fallback to service key');
|
|
96
102
|
console.log(' mcp-auth --env ./mcp.env --service-key ./service-key.json --output ./mcp.env --type xsuaa');
|
|
97
103
|
console.log('');
|
|
98
|
-
console.log(' # XSUAA with
|
|
99
|
-
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --
|
|
100
|
-
console.log('');
|
|
101
|
-
console.log(' # XSUAA with browser OAuth2 (auto - try to open browser, like cf login)');
|
|
102
|
-
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --browser auto');
|
|
104
|
+
console.log(' # XSUAA with client_credentials (special cases)');
|
|
105
|
+
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --credential');
|
|
103
106
|
console.log('');
|
|
104
|
-
console.log(' # XSUAA with
|
|
105
|
-
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --
|
|
107
|
+
console.log(' # XSUAA with custom redirect port');
|
|
108
|
+
console.log(' mcp-auth --service-key ./service-key.json --output ./mcp.env --type xsuaa --redirect-port 8080');
|
|
106
109
|
console.log('');
|
|
107
|
-
console.log(' # ABAP with
|
|
110
|
+
console.log(' # ABAP with authorization_code (default)');
|
|
108
111
|
console.log(' mcp-auth --service-key ./abap-key.json --output ./abap.env --type abap');
|
|
109
112
|
console.log('');
|
|
110
|
-
console.log(' # ABAP with
|
|
111
|
-
console.log(' mcp-auth --service-key ./abap-key.json --output ./abap.env --type abap --
|
|
113
|
+
console.log(' # ABAP with client_credentials (special cases)');
|
|
114
|
+
console.log(' mcp-auth --service-key ./abap-key.json --output ./abap.env --type abap --credential');
|
|
112
115
|
console.log('');
|
|
113
116
|
console.log('Notes:');
|
|
114
117
|
console.log(' - --type determines the provider (xsuaa or abap)');
|
|
115
118
|
console.log(' - If --env is provided and file exists, refresh token is attempted first');
|
|
116
119
|
console.log(' - If refresh fails or env file is missing, service key auth is used');
|
|
117
|
-
console.log(' - Authentication
|
|
118
|
-
console.log(' *
|
|
119
|
-
console.log(' * --
|
|
120
|
-
console.log('
|
|
121
|
-
console.log(' *
|
|
122
|
-
console.log('
|
|
120
|
+
console.log(' - Authentication flow:');
|
|
121
|
+
console.log(' * Default: authorization_code (browser-based OAuth2)');
|
|
122
|
+
console.log(' * --credential: client_credentials (clientId/clientSecret, no browser)');
|
|
123
|
+
console.log(' - Browser options for authorization_code:');
|
|
124
|
+
console.log(' * auto (default): Try to open browser, fallback to showing URL');
|
|
125
|
+
console.log(' * none/headless: Show URL in console and wait for callback');
|
|
126
|
+
console.log(' * system/chrome/edge/firefox: Open specific browser');
|
|
127
|
+
console.log(' - Both providers (xsuaa and abap) support both flows');
|
|
123
128
|
console.log(' - --redirect-port: Port for OAuth redirect URI (default: 3001)');
|
|
124
129
|
console.log(' * Must match redirect_uri configured in XSUAA/ABAP OAuth2 settings');
|
|
125
130
|
console.log(' * Common values: 3001 (default), 8080 (SAP examples)');
|
|
@@ -146,7 +151,8 @@ function parseArgs(): McpAuthOptions | null {
|
|
|
146
151
|
let envFilePath: string | undefined;
|
|
147
152
|
let outputFile: string | undefined;
|
|
148
153
|
let authType: 'abap' | 'xsuaa' = 'abap';
|
|
149
|
-
let browser: string
|
|
154
|
+
let browser: string = 'auto'; // Default to auto for authorization_code flow
|
|
155
|
+
let credential: boolean = false; // Use client_credentials instead of authorization_code
|
|
150
156
|
let format: 'json' | 'env' = 'env';
|
|
151
157
|
let serviceUrl: string | undefined;
|
|
152
158
|
let redirectPort: number | undefined;
|
|
@@ -198,6 +204,8 @@ function parseArgs(): McpAuthOptions | null {
|
|
|
198
204
|
}
|
|
199
205
|
redirectPort = port;
|
|
200
206
|
i++;
|
|
207
|
+
} else if (args[i] === '--credential') {
|
|
208
|
+
credential = true;
|
|
201
209
|
} else {
|
|
202
210
|
console.error(`Unknown option: ${args[i]}`);
|
|
203
211
|
console.error('Run "mcp-auth --help" for usage information');
|
|
@@ -229,6 +237,7 @@ function parseArgs(): McpAuthOptions | null {
|
|
|
229
237
|
outputFile,
|
|
230
238
|
authType,
|
|
231
239
|
browser,
|
|
240
|
+
credential,
|
|
232
241
|
format,
|
|
233
242
|
serviceUrl,
|
|
234
243
|
redirectPort,
|
|
@@ -407,7 +416,10 @@ async function main() {
|
|
|
407
416
|
console.log(`📁 Service key: ${path.resolve(options.serviceKeyPath)}`);
|
|
408
417
|
}
|
|
409
418
|
console.log(`🔐 Auth type: ${options.authType}`);
|
|
410
|
-
console.log(
|
|
419
|
+
console.log(`🔑 Flow: ${options.credential ? 'client_credentials' : 'authorization_code'}`);
|
|
420
|
+
if (!options.credential) {
|
|
421
|
+
console.log(`🌐 Browser: ${options.browser}`);
|
|
422
|
+
}
|
|
411
423
|
console.log(`📄 Format: ${options.format}`);
|
|
412
424
|
if (options.serviceUrl) {
|
|
413
425
|
console.log(`🔗 Service URL: ${options.serviceUrl}`);
|
|
@@ -456,20 +468,21 @@ async function main() {
|
|
|
456
468
|
throw new Error(`Authorization config not found for ${destination}`);
|
|
457
469
|
}
|
|
458
470
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
471
|
+
// Default: authorization_code flow with browser
|
|
472
|
+
// --credential: client_credentials flow (no browser needed)
|
|
473
|
+
const tokenProvider = options.credential
|
|
474
|
+
? new ClientCredentialsProvider({
|
|
462
475
|
uaaUrl: authConfig.uaaUrl,
|
|
463
476
|
clientId: authConfig.uaaClientId,
|
|
464
477
|
clientSecret: authConfig.uaaClientSecret,
|
|
465
|
-
refreshToken: authConfig.refreshToken,
|
|
466
|
-
browser: options.browser,
|
|
467
|
-
redirectPort: options.redirectPort,
|
|
468
478
|
})
|
|
469
|
-
: new
|
|
479
|
+
: new AuthorizationCodeProvider({
|
|
470
480
|
uaaUrl: authConfig.uaaUrl,
|
|
471
481
|
clientId: authConfig.uaaClientId,
|
|
472
482
|
clientSecret: authConfig.uaaClientSecret,
|
|
483
|
+
refreshToken: authConfig.refreshToken,
|
|
484
|
+
browser: options.browser,
|
|
485
|
+
redirectPort: options.redirectPort,
|
|
473
486
|
});
|
|
474
487
|
|
|
475
488
|
const broker = new AuthBroker(
|
|
@@ -486,7 +499,6 @@ async function main() {
|
|
|
486
499
|
console.log(`✅ Token obtained successfully`);
|
|
487
500
|
|
|
488
501
|
const connConfig = await sessionStore.getConnectionConfig(destination);
|
|
489
|
-
const authConfig = await sessionStore.getAuthorizationConfig(destination);
|
|
490
502
|
|
|
491
503
|
if (!token) {
|
|
492
504
|
throw new Error(
|
|
@@ -570,6 +582,9 @@ async function main() {
|
|
|
570
582
|
// Ignore cleanup errors
|
|
571
583
|
}
|
|
572
584
|
|
|
585
|
+
// Exit explicitly to close any open handles (e.g., OAuth callback server)
|
|
586
|
+
process.exit(0);
|
|
587
|
+
|
|
573
588
|
} catch (error: any) {
|
|
574
589
|
console.error(`❌ Error: ${error.message}`);
|
|
575
590
|
if (error.stack) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/auth-broker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "JWT authentication broker for MCP ABAP ADT - manages tokens based on destination headers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"node": ">=18.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
+
"@mcp-abap-adt/auth-broker": "file:mcp-abap-adt-auth-broker-0.2.15.tgz",
|
|
59
60
|
"@mcp-abap-adt/auth-providers": "^0.2.10",
|
|
60
61
|
"@mcp-abap-adt/auth-stores": "^0.2.10",
|
|
61
62
|
"@mcp-abap-adt/interfaces": "^0.2.14",
|