@mcp-abap-adt/auth-broker 1.0.8 → 2.1.0
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 +104 -0
- package/COPYING +674 -0
- package/LICENSE +160 -17
- package/README.md +82 -18
- package/dist/bin/mcp-auth.js +23 -6
- package/dist/bin/mcp-sso.js +15 -202
- package/dist/bin/mcpSsoConfig.js +398 -0
- package/package.json +5 -4
package/LICENSE
CHANGED
|
@@ -1,22 +1,165 @@
|
|
|
1
|
-
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
2
3
|
|
|
3
|
-
Copyright (
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
4
7
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
13
|
+
0. Additional Definitions.
|
|
22
14
|
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
CHANGED
|
@@ -26,13 +26,16 @@ AuthBroker requires a token provider configured for the destination:
|
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
28
|
import { AuthBroker, AbapSessionStore } from '@mcp-abap-adt/auth-broker';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
AuthorizationCodeProvider,
|
|
31
|
+
browserCallbackStrategy,
|
|
32
|
+
} from '@mcp-abap-adt/auth-providers';
|
|
30
33
|
|
|
31
34
|
const tokenProvider = new AuthorizationCodeProvider({
|
|
32
35
|
uaaUrl: 'https://...authentication...hana.ondemand.com',
|
|
33
36
|
clientId: '...',
|
|
34
37
|
clientSecret: '...',
|
|
35
|
-
browser: 'system',
|
|
38
|
+
authorization: browserCallbackStrategy({ browser: 'system' }),
|
|
36
39
|
});
|
|
37
40
|
|
|
38
41
|
const broker = new AuthBroker({
|
|
@@ -53,7 +56,10 @@ import {
|
|
|
53
56
|
AbapServiceKeyStore,
|
|
54
57
|
AbapSessionStore,
|
|
55
58
|
} from '@mcp-abap-adt/auth-broker';
|
|
56
|
-
import {
|
|
59
|
+
import {
|
|
60
|
+
AuthorizationCodeProvider,
|
|
61
|
+
browserCallbackStrategy,
|
|
62
|
+
} from '@mcp-abap-adt/auth-providers';
|
|
57
63
|
|
|
58
64
|
const broker = new AuthBroker({
|
|
59
65
|
sessionStore: new AbapSessionStore('/path/to/destinations'),
|
|
@@ -62,7 +68,7 @@ const broker = new AuthBroker({
|
|
|
62
68
|
uaaUrl: 'https://...authentication...hana.ondemand.com',
|
|
63
69
|
clientId: '...',
|
|
64
70
|
clientSecret: '...',
|
|
65
|
-
browser: 'system',
|
|
71
|
+
authorization: browserCallbackStrategy({ browser: 'system' }),
|
|
66
72
|
}),
|
|
67
73
|
}, 'chrome', logger);
|
|
68
74
|
|
|
@@ -74,7 +80,7 @@ const brokerNoBrowser = new AuthBroker({
|
|
|
74
80
|
uaaUrl: 'https://...authentication...hana.ondemand.com',
|
|
75
81
|
clientId: '...',
|
|
76
82
|
clientSecret: '...',
|
|
77
|
-
browser: 'none',
|
|
83
|
+
authorization: browserCallbackStrategy({ browser: 'none' }),
|
|
78
84
|
}),
|
|
79
85
|
allowBrowserAuth: false, // Throws BROWSER_AUTH_REQUIRED if browser auth needed
|
|
80
86
|
}, 'chrome', logger);
|
|
@@ -92,7 +98,7 @@ const broker = new AuthBroker({
|
|
|
92
98
|
uaaUrl: 'https://...authentication...hana.ondemand.com',
|
|
93
99
|
clientId: '...',
|
|
94
100
|
clientSecret: '...',
|
|
95
|
-
browser: 'system',
|
|
101
|
+
authorization: browserCallbackStrategy({ browser: 'system' }),
|
|
96
102
|
}),
|
|
97
103
|
});
|
|
98
104
|
```
|
|
@@ -111,7 +117,13 @@ const broker = new AuthBroker({
|
|
|
111
117
|
|
|
112
118
|
### Custom Browser Auth Port
|
|
113
119
|
|
|
114
|
-
|
|
120
|
+
How a login is conducted — including which port the local OAuth2 callback
|
|
121
|
+
listens on — is an `IAuthorizationStrategy` passed as `authorization`, not a
|
|
122
|
+
field on the provider config. `browserCallbackStrategy` from
|
|
123
|
+
`@mcp-abap-adt/auth-providers` builds the ready-made one; its default port is
|
|
124
|
+
`61001`, chosen to sit well clear of the range application servers and
|
|
125
|
+
proxies typically use (e.g. `3001`/`3333`). Pass `port` to avoid conflicts
|
|
126
|
+
with a specific redirect URI registered at the identity provider:
|
|
115
127
|
|
|
116
128
|
```typescript
|
|
117
129
|
const broker = new AuthBroker({
|
|
@@ -121,8 +133,7 @@ const broker = new AuthBroker({
|
|
|
121
133
|
uaaUrl: 'https://...authentication...hana.ondemand.com',
|
|
122
134
|
clientId: '...',
|
|
123
135
|
clientSecret: '...',
|
|
124
|
-
browser: 'system',
|
|
125
|
-
redirectPort: 4001,
|
|
136
|
+
authorization: browserCallbackStrategy({ browser: 'system', port: 4001 }),
|
|
126
137
|
}),
|
|
127
138
|
}, 'chrome');
|
|
128
139
|
```
|
|
@@ -572,10 +583,13 @@ The package uses the `ITokenProvider` interface for token acquisition. Provider
|
|
|
572
583
|
- No refresh token provided
|
|
573
584
|
|
|
574
585
|
- **`AuthorizationCodeProvider`** - For BTP/ABAP authentication (full scope)
|
|
575
|
-
-
|
|
576
|
-
|
|
577
|
-
-
|
|
578
|
-
|
|
586
|
+
- How the login is conducted is an `authorization?: IAuthorizationStrategy<string>`, not a
|
|
587
|
+
provider field. Omitted, it defaults to a browser callback on port `61001`
|
|
588
|
+
- `browserCallbackStrategy({ browser?, port?, timeoutMs? })` from `@mcp-abap-adt/auth-providers`
|
|
589
|
+
builds the ready-made strategy; pass `port` to avoid conflicts when running alongside other
|
|
590
|
+
services (e.g. a proxy server) or to match a redirect URI registered at the identity provider
|
|
591
|
+
- The callback port is held only for the duration of a login and released when it ends —
|
|
592
|
+
by success, failure, timeout, or cancellation
|
|
579
593
|
- Uses browser-based OAuth2 flow (if no refresh token)
|
|
580
594
|
- Uses refresh token if available
|
|
581
595
|
- Provides refresh token for future use
|
|
@@ -593,6 +607,7 @@ import {
|
|
|
593
607
|
import {
|
|
594
608
|
ClientCredentialsProvider,
|
|
595
609
|
AuthorizationCodeProvider,
|
|
610
|
+
browserCallbackStrategy,
|
|
596
611
|
} from '@mcp-abap-adt/auth-providers';
|
|
597
612
|
|
|
598
613
|
// XSUAA authentication
|
|
@@ -623,7 +638,7 @@ const btpBroker = new AuthBroker({
|
|
|
623
638
|
uaaUrl: 'https://auth.example.com',
|
|
624
639
|
clientId: '...',
|
|
625
640
|
clientSecret: '...',
|
|
626
|
-
browser: 'system',
|
|
641
|
+
authorization: browserCallbackStrategy({ browser: 'system' }),
|
|
627
642
|
}),
|
|
628
643
|
});
|
|
629
644
|
|
|
@@ -635,7 +650,7 @@ const btpBrokerFull = new AuthBroker({
|
|
|
635
650
|
uaaUrl: 'https://auth.example.com',
|
|
636
651
|
clientId: '...',
|
|
637
652
|
clientSecret: '...',
|
|
638
|
-
browser: 'system',
|
|
653
|
+
authorization: browserCallbackStrategy({ browser: 'system' }),
|
|
639
654
|
}),
|
|
640
655
|
});
|
|
641
656
|
```
|
|
@@ -660,6 +675,14 @@ mcp-auth --service-key <path> --output <path> [--env <path>] [--type abap|xsuaa]
|
|
|
660
675
|
- `none`: Show URL in console and wait for callback (no browser)
|
|
661
676
|
- `system/chrome/edge/firefox`: Open specific browser
|
|
662
677
|
|
|
678
|
+
`--browser` and `--redirect-port` are routed into `browserCallbackStrategy`. This CLI has no
|
|
679
|
+
default of its own for the callback port: `--redirect-port` overrides it when given; omitted,
|
|
680
|
+
the port comes from `auth-providers` (currently `61001`, chosen to sit above the ephemeral range
|
|
681
|
+
and clear of the `3001`/`3333` range servers and proxies typically use). If you registered a
|
|
682
|
+
redirect URI with a specific port at your identity provider, pass `--redirect-port` to match it.
|
|
683
|
+
A login is given 5 minutes to complete (this is a person switching to a browser and signing in
|
|
684
|
+
by hand, not an unattended caller).
|
|
685
|
+
|
|
663
686
|
**Examples:**
|
|
664
687
|
```bash
|
|
665
688
|
# Auth code (default via service key)
|
|
@@ -703,12 +726,22 @@ mcp-sso --protocol <oidc|saml2> --flow <flow> --output <path> [--type abap|xsuaa
|
|
|
703
726
|
- OIDC: `browser`, `device`, `password`, `token_exchange`
|
|
704
727
|
- SAML2: `bearer`, `pure`
|
|
705
728
|
|
|
729
|
+
Only the flows that actually open a browser (OIDC `browser`; SAML2 `bearer`/`pure` with the
|
|
730
|
+
default `--assertion-flow browser`) use `--browser` and `--redirect-port` — they are routed
|
|
731
|
+
into `browserCallbackStrategy`/`oidcCallbackStrategy`/`samlCallbackStrategy`. This CLI has no
|
|
732
|
+
default of its own for the callback port: `--redirect-port` overrides it when given; omitted,
|
|
733
|
+
the port comes from `auth-providers` (currently `61001`). A login is given 5 minutes to
|
|
734
|
+
complete. `device`, `password`, and `token_exchange` never open a browser from this process, so
|
|
735
|
+
`--browser`/`--redirect-port` have no effect for them. This applies the same way whether
|
|
736
|
+
`--protocol`/`--flow` come from CLI flags or from `--config` (below) — a field's origin doesn't
|
|
737
|
+
change how it's handled, and CLI flags always take precedence over the same field in a file.
|
|
738
|
+
|
|
706
739
|
**Examples:**
|
|
707
740
|
```bash
|
|
708
741
|
# OIDC browser flow
|
|
709
742
|
mcp-sso oidc --flow browser --issuer https://issuer --client-id my-client --output ./sso.env --type xsuaa
|
|
710
743
|
|
|
711
|
-
# OIDC browser flow (manual code / OOB)
|
|
744
|
+
# OIDC browser flow (manual code / OOB — no callback server is opened for this combination)
|
|
712
745
|
mcp-sso oidc --flow browser --token-endpoint https://issuer/token --client-id my-client --code <auth_code> --redirect-uri urn:ietf:wg:oauth:2.0:oob --output ./sso.env --type xsuaa
|
|
713
746
|
|
|
714
747
|
# OIDC device flow
|
|
@@ -765,7 +798,8 @@ It enables `authorization_code` and `saml2-bearer` grant types and provides a
|
|
|
765
798
|
simple `CatalogService`. See `tests/sso-demo/readme.md` for deploy steps.
|
|
766
799
|
|
|
767
800
|
**Config file:**
|
|
768
|
-
You can pass a JSON file with provider config
|
|
801
|
+
You can pass a JSON file with provider config instead of (or alongside) `--protocol`/`--flow`
|
|
802
|
+
and the OIDC/SAML flags — `--config` alone is enough to run a flow, with no other flags required:
|
|
769
803
|
|
|
770
804
|
```json
|
|
771
805
|
{
|
|
@@ -777,6 +811,14 @@ You can pass a JSON file with provider config:
|
|
|
777
811
|
}
|
|
778
812
|
```
|
|
779
813
|
|
|
814
|
+
Any CLI flag given alongside `--config` overrides the same field in the file; a field the file
|
|
815
|
+
sets and no flag overrides is used as-is. A file written for a pre-2.0.0 config still works:
|
|
816
|
+
`browser` and `redirectPort` are routed into the strategy exactly as the equivalent CLI flags
|
|
817
|
+
are, and `authorizationCode`/`assertionFlow` are honored the same way `--code`/`--assertion-flow`
|
|
818
|
+
are. A file that sets `authorizationCodeProvider`, `assertionProvider`, or `manualInput` — all
|
|
819
|
+
functions, which JSON cannot express — is refused with an error naming the CLI flag to use
|
|
820
|
+
instead, rather than having the field silently dropped.
|
|
821
|
+
|
|
780
822
|
### Utility Script
|
|
781
823
|
|
|
782
824
|
Generate `.env` files from service keys:
|
|
@@ -855,4 +897,26 @@ Thank you to all contributors! See [CONTRIBUTORS.md](CONTRIBUTORS.md) for the co
|
|
|
855
897
|
|
|
856
898
|
## License
|
|
857
899
|
|
|
858
|
-
|
|
900
|
+
**GNU Lesser General Public License v3.0 only** (`LGPL-3.0-only`).
|
|
901
|
+
Earlier published versions were MIT and stay MIT — a licence change is not
|
|
902
|
+
retroactive.
|
|
903
|
+
|
|
904
|
+
Copyright © 2025–2026 Oleksii Kyslytsia
|
|
905
|
+
|
|
906
|
+
This library is free software: you can redistribute it and/or modify it under the
|
|
907
|
+
terms of the GNU Lesser General Public License as published by the Free Software
|
|
908
|
+
Foundation, version 3.
|
|
909
|
+
|
|
910
|
+
It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
911
|
+
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
912
|
+
PURPOSE. See the GNU Lesser General Public License for more details.
|
|
913
|
+
|
|
914
|
+
Both texts ship with the package and both are needed: [`LICENSE`](LICENSE) is the
|
|
915
|
+
LGPL, [`COPYING`](COPYING) is the GPL it is written on top of, since the LGPL is a
|
|
916
|
+
set of additional permissions over the GPL and cannot be read alone.
|
|
917
|
+
|
|
918
|
+
**What this means if you depend on this package.** Linking it into your own
|
|
919
|
+
program — importing it, as every consumer of an npm package does — does not put
|
|
920
|
+
your program under the LGPL. What the licence asks is that changes *to this
|
|
921
|
+
library* stay free, and that your users can replace it with their own build.
|
|
922
|
+
|
package/dist/bin/mcp-auth.js
CHANGED
|
@@ -61,6 +61,11 @@ const distPath = path.resolve(__dirname, '..', 'index.js');
|
|
|
61
61
|
const { AuthBroker } = require(distPath);
|
|
62
62
|
const auth_providers_1 = require("@mcp-abap-adt/auth-providers");
|
|
63
63
|
const auth_stores_1 = require("@mcp-abap-adt/auth-stores");
|
|
64
|
+
/**
|
|
65
|
+
* A person completes this login at a browser; the provider's own default
|
|
66
|
+
* (30s) is sized for an unattended caller instead.
|
|
67
|
+
*/
|
|
68
|
+
const INTERACTIVE_LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
64
69
|
function getVersion() {
|
|
65
70
|
try {
|
|
66
71
|
const candidates = [
|
|
@@ -108,7 +113,8 @@ function showHelp() {
|
|
|
108
113
|
console.log(' - system/chrome/edge/firefox: Open specific browser');
|
|
109
114
|
console.log(' --format <format> Output format: json or env (default: env)');
|
|
110
115
|
console.log(' --service-url <url> Service URL (SAP URL for ABAP, MCP URL for XSUAA). For XSUAA, optional.');
|
|
111
|
-
console.log(' --redirect-port <port> Port for OAuth redirect URI (default:
|
|
116
|
+
console.log(' --redirect-port <port> Port for OAuth redirect URI (default: from auth-providers, currently 61001).');
|
|
117
|
+
console.log(' Must match XSUAA redirect-uris config.');
|
|
112
118
|
console.log('');
|
|
113
119
|
console.log(' --version, -v Show version number');
|
|
114
120
|
console.log(' --help, -h Show this help message');
|
|
@@ -159,9 +165,9 @@ function showHelp() {
|
|
|
159
165
|
console.log(' * none/headless: Show URL in console and wait for callback');
|
|
160
166
|
console.log(' * system/chrome/edge/firefox: Open specific browser');
|
|
161
167
|
console.log(' - Both providers (xsuaa and abap) support both flows');
|
|
162
|
-
console.log(' - --redirect-port: Port for OAuth redirect URI (default:
|
|
168
|
+
console.log(' - --redirect-port: Port for OAuth redirect URI (default: from auth-providers, currently 61001)');
|
|
163
169
|
console.log(' * Must match redirect_uri configured in XSUAA/ABAP OAuth2 settings');
|
|
164
|
-
console.log(' *
|
|
170
|
+
console.log(' * If your registered redirect URI uses a different port (e.g. 3001, 8080), pass it explicitly');
|
|
165
171
|
console.log(' - For XSUAA, serviceUrl (MCP URL) is optional - can be provided via --service-url or service key');
|
|
166
172
|
console.log(' - For ABAP, serviceUrl (SAP URL) is required - can be provided via --service-url or service key');
|
|
167
173
|
console.log(' - SAP_URL/XSUAA_MCP_URL is written to .env (from --service-url, service key, or placeholder)');
|
|
@@ -599,7 +605,12 @@ async function main() {
|
|
|
599
605
|
}
|
|
600
606
|
// Default: authorization_code flow with browser
|
|
601
607
|
// --credential: client_credentials flow (no browser needed)
|
|
602
|
-
|
|
608
|
+
// The callback port is the provider's own choice (DEFAULT_CALLBACK_PORT,
|
|
609
|
+
// currently 61001) unless the user overrides it with --redirect-port.
|
|
610
|
+
// Only resolved to a concrete number here for the URL preview below —
|
|
611
|
+
// the strategy itself re-derives the same default independently when
|
|
612
|
+
// `port` is left undefined.
|
|
613
|
+
const redirectPort = options.redirectPort ?? auth_providers_1.DEFAULT_CALLBACK_PORT;
|
|
603
614
|
// Log authorization URL for debugging
|
|
604
615
|
if (!options.credential) {
|
|
605
616
|
const redirectUri = `http://localhost:${redirectPort}/callback`;
|
|
@@ -618,8 +629,14 @@ async function main() {
|
|
|
618
629
|
clientId: authConfig.uaaClientId,
|
|
619
630
|
clientSecret: authConfig.uaaClientSecret,
|
|
620
631
|
refreshToken: authConfig.refreshToken,
|
|
621
|
-
|
|
622
|
-
|
|
632
|
+
// Passing `options.redirectPort` (not the resolved `redirectPort`
|
|
633
|
+
// above) so an omitted --redirect-port lets the strategy bind its
|
|
634
|
+
// own default rather than this CLI pinning a number it doesn't own.
|
|
635
|
+
authorization: (0, auth_providers_1.browserCallbackStrategy)({
|
|
636
|
+
browser: options.browser,
|
|
637
|
+
port: options.redirectPort,
|
|
638
|
+
timeoutMs: INTERACTIVE_LOGIN_TIMEOUT_MS,
|
|
639
|
+
}),
|
|
623
640
|
});
|
|
624
641
|
const broker = new AuthBroker({
|
|
625
642
|
sessionStore,
|