@mcp-abap-adt/auth-providers 1.2.0 → 2.2.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 +135 -0
- package/COPYING +674 -0
- package/LICENSE +160 -17
- package/README.md +401 -66
- package/bin/auth-authorization-code.ts +5 -3
- package/dist/__tests__/helpers/netHelpers.d.ts +16 -0
- package/dist/__tests__/helpers/netHelpers.d.ts.map +1 -1
- package/dist/__tests__/helpers/netHelpers.js +29 -0
- package/dist/__tests__/helpers/testLogger.d.ts +1 -1
- package/dist/__tests__/helpers/testLogger.d.ts.map +1 -1
- package/dist/auth/announce.d.ts +11 -0
- package/dist/auth/announce.d.ts.map +1 -0
- package/dist/auth/announce.js +19 -0
- package/dist/auth/browserAuth.d.ts +23 -15
- package/dist/auth/browserAuth.d.ts.map +1 -1
- package/dist/auth/browserAuth.js +25 -111
- package/dist/auth/callbackServer.d.ts +7 -1
- package/dist/auth/callbackServer.d.ts.map +1 -1
- package/dist/auth/callbackServer.js +31 -21
- package/dist/auth/deviceFlowAuth.d.ts +1 -1
- package/dist/auth/deviceFlowAuth.d.ts.map +1 -1
- package/dist/auth/oidcBrowserAuth.d.ts +2 -9
- package/dist/auth/oidcBrowserAuth.d.ts.map +1 -1
- package/dist/auth/oidcBrowserAuth.js +16 -125
- package/dist/auth/oidcDiscovery.d.ts +1 -1
- package/dist/auth/oidcDiscovery.d.ts.map +1 -1
- package/dist/auth/oidcToken.d.ts +1 -1
- package/dist/auth/oidcToken.d.ts.map +1 -1
- package/dist/auth/saml2Auth.d.ts +2 -9
- package/dist/auth/saml2Auth.d.ts.map +1 -1
- package/dist/auth/saml2Auth.js +10 -130
- package/dist/auth/saml2TokenExchange.d.ts +1 -1
- package/dist/auth/saml2TokenExchange.d.ts.map +1 -1
- package/dist/errors/TokenProviderErrors.js +6 -6
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -1
- package/dist/providers/AuthorizationCodeProvider.d.ts +8 -3
- package/dist/providers/AuthorizationCodeProvider.d.ts.map +1 -1
- package/dist/providers/AuthorizationCodeProvider.js +55 -44
- package/dist/providers/BaseTokenProvider.d.ts +2 -1
- package/dist/providers/BaseTokenProvider.d.ts.map +1 -1
- package/dist/providers/ClientCredentialsProvider.d.ts +1 -1
- package/dist/providers/ClientCredentialsProvider.d.ts.map +1 -1
- package/dist/providers/ClientCredentialsProvider.js +3 -3
- package/dist/providers/DeviceFlowProvider.d.ts +3 -1
- package/dist/providers/DeviceFlowProvider.d.ts.map +1 -1
- package/dist/providers/DeviceFlowProvider.js +17 -14
- package/dist/providers/OidcBrowserProvider.d.ts +5 -7
- package/dist/providers/OidcBrowserProvider.d.ts.map +1 -1
- package/dist/providers/OidcBrowserProvider.js +58 -61
- package/dist/providers/OidcDeviceFlowProvider.d.ts +2 -1
- package/dist/providers/OidcDeviceFlowProvider.d.ts.map +1 -1
- package/dist/providers/OidcDeviceFlowProvider.js +13 -11
- package/dist/providers/OidcPasswordProvider.d.ts +2 -1
- package/dist/providers/OidcPasswordProvider.d.ts.map +1 -1
- package/dist/providers/OidcPasswordProvider.js +4 -4
- package/dist/providers/OidcTokenExchangeProvider.d.ts +2 -1
- package/dist/providers/OidcTokenExchangeProvider.d.ts.map +1 -1
- package/dist/providers/OidcTokenExchangeProvider.js +3 -3
- package/dist/providers/Saml2BearerProvider.d.ts +4 -3
- package/dist/providers/Saml2BearerProvider.d.ts.map +1 -1
- package/dist/providers/Saml2BearerProvider.js +6 -3
- package/dist/providers/Saml2PureProvider.d.ts +4 -3
- package/dist/providers/Saml2PureProvider.d.ts.map +1 -1
- package/dist/providers/Saml2PureProvider.js +6 -3
- package/dist/providers/saml2Utils.d.ts +13 -12
- package/dist/providers/saml2Utils.d.ts.map +1 -1
- package/dist/providers/saml2Utils.js +46 -26
- package/dist/sso/SsoProviderFactory.d.ts +1 -1
- package/dist/sso/SsoProviderFactory.d.ts.map +1 -1
- package/dist/sso/types.d.ts +1 -1
- package/dist/sso/types.d.ts.map +1 -1
- package/dist/strategies/BrowserCallbackStrategy.d.ts +64 -0
- package/dist/strategies/BrowserCallbackStrategy.d.ts.map +1 -0
- package/dist/strategies/BrowserCallbackStrategy.js +210 -0
- package/dist/strategies/asOidcResult.d.ts +11 -0
- package/dist/strategies/asOidcResult.d.ts.map +1 -0
- package/dist/strategies/asOidcResult.js +30 -0
- package/dist/strategies/codeStrategies.d.ts +22 -0
- package/dist/strategies/codeStrategies.d.ts.map +1 -0
- package/dist/strategies/codeStrategies.js +39 -0
- package/dist/strategies/index.d.ts +8 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +18 -0
- package/dist/strategies/manualStrategies.d.ts +20 -0
- package/dist/strategies/manualStrategies.d.ts.map +1 -0
- package/dist/strategies/manualStrategies.js +77 -0
- package/package.json +8 -5
- package/dist/auth/manualInput.d.ts +0 -5
- package/dist/auth/manualInput.d.ts.map +0 -1
- package/dist/auth/manualInput.js +0 -19
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OidcPasswordProvider = void 0;
|
|
7
|
-
const
|
|
7
|
+
const interfaces_auth_1 = require("@mcp-abap-adt/interfaces-auth");
|
|
8
8
|
const oidcDiscovery_1 = require("../auth/oidcDiscovery");
|
|
9
9
|
const oidcToken_1 = require("../auth/oidcToken");
|
|
10
10
|
const BaseTokenProvider_1 = require("./BaseTokenProvider");
|
|
@@ -23,7 +23,7 @@ class OidcPasswordProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
getAuthType() {
|
|
26
|
-
return
|
|
26
|
+
return interfaces_auth_1.AUTH_TYPE_PASSWORD;
|
|
27
27
|
}
|
|
28
28
|
async performLogin() {
|
|
29
29
|
if (!this.config.tokenEndpoint && !this.config.issuerUrl) {
|
|
@@ -45,7 +45,7 @@ class OidcPasswordProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
45
45
|
return {
|
|
46
46
|
authorizationToken: tokens.accessToken,
|
|
47
47
|
refreshToken: tokens.refreshToken,
|
|
48
|
-
authType:
|
|
48
|
+
authType: interfaces_auth_1.AUTH_TYPE_PASSWORD,
|
|
49
49
|
expiresIn: tokens.expiresIn,
|
|
50
50
|
tokenType: 'jwt',
|
|
51
51
|
};
|
|
@@ -72,7 +72,7 @@ class OidcPasswordProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
72
72
|
return {
|
|
73
73
|
authorizationToken: tokens.accessToken,
|
|
74
74
|
refreshToken: tokens.refreshToken || this.refreshToken,
|
|
75
|
-
authType:
|
|
75
|
+
authType: interfaces_auth_1.AUTH_TYPE_PASSWORD,
|
|
76
76
|
expiresIn: tokens.expiresIn,
|
|
77
77
|
tokenType: 'jwt',
|
|
78
78
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OIDC Token Exchange Provider
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { ITokenResult, OAuth2GrantType } from '@mcp-abap-adt/interfaces-auth';
|
|
5
|
+
import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
|
|
5
6
|
import { BaseTokenProvider } from './BaseTokenProvider';
|
|
6
7
|
export interface OidcTokenExchangeProviderConfig {
|
|
7
8
|
issuerUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcTokenExchangeProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OidcTokenExchangeProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"OidcTokenExchangeProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OidcTokenExchangeProvider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,+BAA+B;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,yBAA0B,SAAQ,iBAAiB;IAC9D,OAAO,CAAC,MAAM,CAAkC;gBAEpC,MAAM,EAAE,+BAA+B;IAcnD,SAAS,CAAC,WAAW,IAAI,eAAe;cAIxB,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC;cAwCrC,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC;CAGxD"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OidcTokenExchangeProvider = void 0;
|
|
7
|
-
const
|
|
7
|
+
const interfaces_auth_1 = require("@mcp-abap-adt/interfaces-auth");
|
|
8
8
|
const oidcDiscovery_1 = require("../auth/oidcDiscovery");
|
|
9
9
|
const oidcToken_1 = require("../auth/oidcToken");
|
|
10
10
|
const BaseTokenProvider_1 = require("./BaseTokenProvider");
|
|
@@ -23,7 +23,7 @@ class OidcTokenExchangeProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
getAuthType() {
|
|
26
|
-
return
|
|
26
|
+
return interfaces_auth_1.AUTH_TYPE_USER_TOKEN;
|
|
27
27
|
}
|
|
28
28
|
async performLogin() {
|
|
29
29
|
if (!this.config.tokenEndpoint && !this.config.issuerUrl) {
|
|
@@ -44,7 +44,7 @@ class OidcTokenExchangeProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
44
44
|
return {
|
|
45
45
|
authorizationToken: tokens.accessToken,
|
|
46
46
|
refreshToken: tokens.refreshToken,
|
|
47
|
-
authType:
|
|
47
|
+
authType: interfaces_auth_1.AUTH_TYPE_USER_TOKEN,
|
|
48
48
|
expiresIn: tokens.expiresIn,
|
|
49
49
|
tokenType: 'jwt',
|
|
50
50
|
};
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exchanges SAMLResponse for OAuth2 access token.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { ITokenResult, OAuth2GrantType } from '@mcp-abap-adt/interfaces-auth';
|
|
7
|
+
import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
|
|
7
8
|
import { BaseTokenProvider } from './BaseTokenProvider';
|
|
8
|
-
import type {
|
|
9
|
-
export interface Saml2BearerProviderConfig extends
|
|
9
|
+
import type { Saml2BearerExchangeConfig, Saml2CommonConfig } from './saml2Utils';
|
|
10
|
+
export interface Saml2BearerProviderConfig extends Saml2CommonConfig, Saml2BearerExchangeConfig {
|
|
10
11
|
logger?: ILogger;
|
|
11
12
|
accessToken?: string;
|
|
12
13
|
refreshToken?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2BearerProvider.d.ts","sourceRoot":"","sources":["../../src/providers/Saml2BearerProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"Saml2BearerProvider.d.ts","sourceRoot":"","sources":["../../src/providers/Saml2BearerProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAOtB,MAAM,WAAW,yBACf,SAAQ,iBAAiB,EACvB,yBAAyB;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,mBAAoB,SAAQ,iBAAiB;IACxD,OAAO,CAAC,MAAM,CAA4B;gBAE9B,MAAM,EAAE,yBAAyB;IAiB7C,SAAS,CAAC,WAAW,IAAI,eAAe;cAIxB,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC;cAoBrC,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC;CAMxD"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.Saml2BearerProvider = void 0;
|
|
9
|
-
const
|
|
9
|
+
const interfaces_auth_1 = require("@mcp-abap-adt/interfaces-auth");
|
|
10
10
|
const saml2TokenExchange_1 = require("../auth/saml2TokenExchange");
|
|
11
11
|
const BaseTokenProvider_1 = require("./BaseTokenProvider");
|
|
12
12
|
const saml2Utils_1 = require("./saml2Utils");
|
|
@@ -14,6 +14,9 @@ class Saml2BearerProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
14
14
|
config;
|
|
15
15
|
constructor(config) {
|
|
16
16
|
super();
|
|
17
|
+
// A pre-built URL with no declared ACS cannot be verified against whatever
|
|
18
|
+
// the strategy binds, so it is refused here rather than at login time.
|
|
19
|
+
(0, saml2Utils_1.validateSamlConfig)(config);
|
|
17
20
|
this.config = config;
|
|
18
21
|
this.logger = config.logger;
|
|
19
22
|
if (config.accessToken) {
|
|
@@ -25,7 +28,7 @@ class Saml2BearerProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
getAuthType() {
|
|
28
|
-
return
|
|
31
|
+
return interfaces_auth_1.AUTH_TYPE_SAML2_BEARER;
|
|
29
32
|
}
|
|
30
33
|
async performLogin() {
|
|
31
34
|
const samlResponse = await (0, saml2Utils_1.getSamlAssertion)(this.config);
|
|
@@ -34,7 +37,7 @@ class Saml2BearerProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
34
37
|
return {
|
|
35
38
|
authorizationToken: tokens.accessToken,
|
|
36
39
|
refreshToken: tokens.refreshToken,
|
|
37
|
-
authType:
|
|
40
|
+
authType: interfaces_auth_1.AUTH_TYPE_SAML2_BEARER,
|
|
38
41
|
expiresIn: tokens.expiresIn,
|
|
39
42
|
tokenType: 'jwt',
|
|
40
43
|
};
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Returns SAMLResponse as authorizationToken (non-JWT).
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { ITokenResult, OAuth2GrantType } from '@mcp-abap-adt/interfaces-auth';
|
|
7
|
+
import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
|
|
7
8
|
import { BaseTokenProvider } from './BaseTokenProvider';
|
|
8
|
-
import type {
|
|
9
|
-
export interface Saml2PureProviderConfig extends
|
|
9
|
+
import type { Saml2CommonConfig } from './saml2Utils';
|
|
10
|
+
export interface Saml2PureProviderConfig extends Saml2CommonConfig {
|
|
10
11
|
logger?: ILogger;
|
|
11
12
|
cookieProvider: (samlResponse: string) => Promise<string>;
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2PureProvider.d.ts","sourceRoot":"","sources":["../../src/providers/Saml2PureProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"Saml2PureProvider.d.ts","sourceRoot":"","sources":["../../src/providers/Saml2PureProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3D;AAED,qBAAa,iBAAkB,SAAQ,iBAAiB;IACtD,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,EAAE,uBAAuB;IAU3C,SAAS,CAAC,WAAW,IAAI,eAAe;cAIxB,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC;cAarC,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC;CAGxD"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.Saml2PureProvider = void 0;
|
|
9
|
-
const
|
|
9
|
+
const interfaces_auth_1 = require("@mcp-abap-adt/interfaces-auth");
|
|
10
10
|
const saml2Auth_1 = require("../auth/saml2Auth");
|
|
11
11
|
const BaseTokenProvider_1 = require("./BaseTokenProvider");
|
|
12
12
|
const saml2Utils_1 = require("./saml2Utils");
|
|
@@ -14,12 +14,15 @@ class Saml2PureProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
14
14
|
config;
|
|
15
15
|
constructor(config) {
|
|
16
16
|
super();
|
|
17
|
+
// A pre-built URL with no declared ACS cannot be verified against whatever
|
|
18
|
+
// the strategy binds, so it is refused here rather than at login time.
|
|
19
|
+
(0, saml2Utils_1.validateSamlConfig)(config);
|
|
17
20
|
this.config = config;
|
|
18
21
|
this.logger = config.logger;
|
|
19
22
|
this.tokenType = 'saml';
|
|
20
23
|
}
|
|
21
24
|
getAuthType() {
|
|
22
|
-
return
|
|
25
|
+
return interfaces_auth_1.AUTH_TYPE_USER_TOKEN;
|
|
23
26
|
}
|
|
24
27
|
async performLogin() {
|
|
25
28
|
const samlResponse = await (0, saml2Utils_1.getSamlAssertion)(this.config);
|
|
@@ -27,7 +30,7 @@ class Saml2PureProvider extends BaseTokenProvider_1.BaseTokenProvider {
|
|
|
27
30
|
const sessionCookies = await this.config.cookieProvider(samlResponse);
|
|
28
31
|
return {
|
|
29
32
|
authorizationToken: sessionCookies,
|
|
30
|
-
authType:
|
|
33
|
+
authType: interfaces_auth_1.AUTH_TYPE_USER_TOKEN,
|
|
31
34
|
tokenType: 'saml',
|
|
32
35
|
expiresAt,
|
|
33
36
|
};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SAML2 provider shared helpers
|
|
2
|
+
* SAML2 provider shared helpers.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type { IAuthorizationStrategy } from '@mcp-abap-adt/interfaces-auth';
|
|
5
|
+
import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
|
|
6
6
|
export interface Saml2CommonConfig {
|
|
7
7
|
idpSsoUrl: string;
|
|
8
8
|
spEntityId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Where the assertion is delivered. Required when `authorizationUrl` is set:
|
|
11
|
+
* the ACS is then buried in a deflated `SAMLRequest` this package did not
|
|
12
|
+
* build and cannot read, so it must be declared rather than inferred.
|
|
13
|
+
*/
|
|
9
14
|
acsUrl?: string;
|
|
10
15
|
relayState?: string;
|
|
11
16
|
authorizationUrl?: string;
|
|
12
|
-
browser
|
|
13
|
-
|
|
17
|
+
/** How the login is conducted. Omitted means a browser callback. */
|
|
18
|
+
authorization?: IAuthorizationStrategy<string>;
|
|
14
19
|
logger?: ILogger;
|
|
15
20
|
}
|
|
16
|
-
export interface Saml2AssertionConfig extends Saml2CommonConfig {
|
|
17
|
-
assertionFlow: Saml2AssertionFlow;
|
|
18
|
-
assertionProvider?: () => Promise<string>;
|
|
19
|
-
manualInput?: () => Promise<string>;
|
|
20
|
-
}
|
|
21
21
|
export interface Saml2BearerExchangeConfig {
|
|
22
22
|
tokenUrl?: string;
|
|
23
23
|
uaaUrl?: string;
|
|
24
24
|
clientId?: string;
|
|
25
25
|
clientSecret?: string;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
/** Throw at construction rather than half-verify at runtime. */
|
|
28
|
+
export declare function validateSamlConfig(config: Saml2CommonConfig): void;
|
|
28
29
|
export declare function resolveTokenUrl(config: Saml2BearerExchangeConfig): string;
|
|
29
|
-
export declare function getSamlAssertion(config:
|
|
30
|
+
export declare function getSamlAssertion(config: Saml2CommonConfig): Promise<string>;
|
|
30
31
|
//# sourceMappingURL=saml2Utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saml2Utils.d.ts","sourceRoot":"","sources":["../../src/providers/saml2Utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"saml2Utils.d.ts","sourceRoot":"","sources":["../../src/providers/saml2Utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAI9D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,aAAa,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAOlE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,CAQzE;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* SAML2 provider shared helpers
|
|
3
|
+
* SAML2 provider shared helpers.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.validateSamlConfig = validateSamlConfig;
|
|
7
7
|
exports.resolveTokenUrl = resolveTokenUrl;
|
|
8
8
|
exports.getSamlAssertion = getSamlAssertion;
|
|
9
|
-
const manualInput_1 = require("../auth/manualInput");
|
|
10
9
|
const saml2Auth_1 = require("../auth/saml2Auth");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const strategies_1 = require("../strategies");
|
|
11
|
+
/** Throw at construction rather than half-verify at runtime. */
|
|
12
|
+
function validateSamlConfig(config) {
|
|
13
|
+
if (config.authorizationUrl && !config.acsUrl) {
|
|
14
|
+
throw new Error('acsUrl is required when authorizationUrl is set: the ACS inside a ' +
|
|
15
|
+
'pre-built SAML request cannot be read, so it must be declared.');
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
function resolveTokenUrl(config) {
|
|
16
19
|
if (config.tokenUrl) {
|
|
@@ -22,28 +25,45 @@ function resolveTokenUrl(config) {
|
|
|
22
25
|
throw new Error('Missing tokenUrl or uaaUrl for SAML bearer exchange');
|
|
23
26
|
}
|
|
24
27
|
async function getSamlAssertion(config) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const declaredAcs = config.acsUrl;
|
|
29
|
+
const request = {
|
|
30
|
+
logger: config.logger,
|
|
31
|
+
buildAuthorizationUrl: async (redirectUri) => {
|
|
32
|
+
// A declared ACS is registered with the IdP; the strategy must be
|
|
33
|
+
// listening exactly there, and an ephemeral port cannot be.
|
|
34
|
+
const acsUrl = declaredAcs ?? redirectUri;
|
|
35
|
+
if (declaredAcs && declaredAcs !== redirectUri) {
|
|
36
|
+
throw new Error(`SAML acsUrl is ${declaredAcs}, but the authorization strategy is ` +
|
|
37
|
+
`listening on ${redirectUri}. They must match.`);
|
|
38
|
+
}
|
|
39
|
+
return (0, saml2Auth_1.buildSamlAuthorizationUrl)({
|
|
40
|
+
idpSsoUrl: config.idpSsoUrl,
|
|
41
|
+
spEntityId: config.spEntityId,
|
|
42
|
+
acsUrl,
|
|
43
|
+
relayState: config.relayState,
|
|
44
|
+
authorizationUrl: config.authorizationUrl,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
32
47
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
const supplied = config.authorization;
|
|
49
|
+
const strategy = supplied ?? (0, strategies_1.samlCallbackStrategy)();
|
|
50
|
+
try {
|
|
51
|
+
const outcome = await strategy.authorize(request);
|
|
52
|
+
// The second net, for a strategy that never called the builder and so
|
|
53
|
+
// never met the check inside it.
|
|
54
|
+
if (declaredAcs && declaredAcs !== outcome.redirectUri) {
|
|
55
|
+
throw new Error(`SAML acsUrl is ${declaredAcs}, but the authorization strategy used ` +
|
|
56
|
+
`${outcome.redirectUri}. They must match.`);
|
|
36
57
|
}
|
|
37
|
-
return
|
|
58
|
+
return outcome.payload;
|
|
38
59
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
finally {
|
|
61
|
+
if (!supplied) {
|
|
62
|
+
await strategy.dispose?.().catch((error) => {
|
|
63
|
+
config.logger?.warn('[SAML] dispose failed', {
|
|
64
|
+
error: error instanceof Error ? error.message : String(error),
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
46
68
|
}
|
|
47
|
-
const browser = config.browser || 'auto';
|
|
48
|
-
return await (0, saml2Auth_1.startSamlBrowserAuth)(authConfig, browser, config.logger, config.redirectPort || 3001);
|
|
49
69
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ITokenProvider } from '@mcp-abap-adt/interfaces';
|
|
1
|
+
import type { ITokenProvider } from '@mcp-abap-adt/interfaces-auth';
|
|
2
2
|
import type { SsoProviderConfig } from './types';
|
|
3
3
|
export declare class SsoProviderFactory {
|
|
4
4
|
static create(config: SsoProviderConfig): ITokenProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SsoProviderFactory.d.ts","sourceRoot":"","sources":["../../src/sso/SsoProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SsoProviderFactory.d.ts","sourceRoot":"","sources":["../../src/sso/SsoProviderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAOpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,cAAc;CA6BzD"}
|
package/dist/sso/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ITokenProvider } from '@mcp-abap-adt/interfaces';
|
|
1
|
+
import type { ITokenProvider } from '@mcp-abap-adt/interfaces-auth';
|
|
2
2
|
import type { OidcBrowserProviderConfig } from '../providers/OidcBrowserProvider';
|
|
3
3
|
import type { OidcDeviceFlowProviderConfig } from '../providers/OidcDeviceFlowProvider';
|
|
4
4
|
import type { OidcPasswordProviderConfig } from '../providers/OidcPasswordProvider';
|
package/dist/sso/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sso/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sso/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,yBAAyB,CAAC;CACnC,GACD;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,4BAA4B,CAAC;CACtC,GACD;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,0BAA0B,CAAC;CACpC,GACD;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,+BAA+B,CAAC;CACzC,GACD;IACE,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,yBAAyB,CAAC;CACnC,GACD;IACE,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,uBAAuB,CAAC;CACjC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reaching the authorization URL with a browser, receiving the redirect on a
|
|
3
|
+
* local socket.
|
|
4
|
+
*
|
|
5
|
+
* The transport is injected rather than assumed: a consumer that already runs
|
|
6
|
+
* an HTTP server can pass its own `CallbackServerFactory` and keep everything
|
|
7
|
+
* else here.
|
|
8
|
+
*/
|
|
9
|
+
import type { AuthorizationOutcome, AuthorizationRequest, CallbackServerFactory, IAuthorizationStrategy } from '@mcp-abap-adt/interfaces-auth';
|
|
10
|
+
import type { OidcCallbackResult } from '../auth/oidcBrowserAuth';
|
|
11
|
+
/**
|
|
12
|
+
* Above Linux's `ip_local_port_range` (32768–60999), so an outbound connection
|
|
13
|
+
* never squats on it, and far from the 3001/3333 range application servers use.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_CALLBACK_PORT = 61001;
|
|
16
|
+
/** How long an interactive login may wait for its callback. */
|
|
17
|
+
export declare const DEFAULT_LOGIN_TIMEOUT_MS = 30000;
|
|
18
|
+
export interface CallbackStrategyOptions<TResult = string> {
|
|
19
|
+
/** `0` binds an ephemeral port. Unusable where the IdP has a registered URI. */
|
|
20
|
+
port?: number;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
/** 'none' | 'headless' print the URL; 'auto' | 'system' | 'chrome' | … open it. */
|
|
23
|
+
browser?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The transport. Omitted means the one this package ships for the flow; a
|
|
26
|
+
* consumer that already runs an HTTP server passes its own here and keeps
|
|
27
|
+
* everything else — which is the point of the ready constructors existing at
|
|
28
|
+
* all rather than forcing everyone through the class.
|
|
29
|
+
*/
|
|
30
|
+
callbackServer?: CallbackServerFactory<TResult>;
|
|
31
|
+
/** Receives the bound redirect URI too, since with `port: 0` nobody knew it earlier. */
|
|
32
|
+
openUrl?: (url: string, browser: string, redirectUri: string) => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Extra guidance for 'none'/'headless', built from the URI actually bound —
|
|
35
|
+
* "if your browser is elsewhere, do this instead".
|
|
36
|
+
*
|
|
37
|
+
* It describes a *route*, so it belongs to whoever supplied the transport. A
|
|
38
|
+
* consumer injecting its own `callbackServer` states its own hint here; the
|
|
39
|
+
* package supplies one only for the transport it ships, and never guesses on
|
|
40
|
+
* behalf of an injected one.
|
|
41
|
+
*/
|
|
42
|
+
remoteHint?: (redirectUri: string) => string;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}
|
|
45
|
+
export interface BrowserCallbackStrategyOptions<TResult> extends CallbackStrategyOptions<TResult> {
|
|
46
|
+
callbackServer: CallbackServerFactory<TResult>;
|
|
47
|
+
}
|
|
48
|
+
export declare class BrowserCallbackStrategy<TResult> implements IAuthorizationStrategy<TResult> {
|
|
49
|
+
private readonly options;
|
|
50
|
+
private inFlight;
|
|
51
|
+
private controller;
|
|
52
|
+
private disposed;
|
|
53
|
+
constructor(options: BrowserCallbackStrategyOptions<TResult>);
|
|
54
|
+
authorize(request: AuthorizationRequest): Promise<AuthorizationOutcome<TResult>>;
|
|
55
|
+
/**
|
|
56
|
+
* Idempotent; ends an authorization in flight and resolves only once the
|
|
57
|
+
* factory has settled — which it does after the socket is free.
|
|
58
|
+
*/
|
|
59
|
+
dispose(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare function browserCallbackStrategy(options?: CallbackStrategyOptions<string>): IAuthorizationStrategy<string>;
|
|
62
|
+
export declare function oidcCallbackStrategy(options?: CallbackStrategyOptions<OidcCallbackResult>): IAuthorizationStrategy<OidcCallbackResult>;
|
|
63
|
+
export declare function samlCallbackStrategy(options?: CallbackStrategyOptions<string>): IAuthorizationStrategy<string>;
|
|
64
|
+
//# sourceMappingURL=BrowserCallbackStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserCallbackStrategy.d.ts","sourceRoot":"","sources":["../../src/strategies/BrowserCallbackStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C,MAAM,WAAW,uBAAuB,CAAC,OAAO,GAAG,MAAM;IACvD,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAChD,wFAAwF;IACxF,OAAO,CAAC,EAAE,CACR,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,KAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,8BAA8B,CAAC,OAAO,CACrD,SAAQ,uBAAuB,CAAC,OAAO,CAAC;IACxC,cAAc,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;CAChD;AAwBD,qBAAa,uBAAuB,CAAC,OAAO,CAC1C,YAAW,sBAAsB,CAAC,OAAO,CAAC;IAOxC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAuD;IACvE,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,QAAQ,CAAS;gBAGN,OAAO,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAG7D,SAAS,CACb,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IA8FzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B;AAyBD,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,uBAAuB,CAAC,MAAM,CAAM,GAC5C,sBAAsB,CAAC,MAAM,CAAC,CAWhC;AAED,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,uBAAuB,CAAC,kBAAkB,CAAM,GACxD,sBAAsB,CAAC,kBAAkB,CAAC,CAK5C;AAED,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,uBAAuB,CAAC,MAAM,CAAM,GAC5C,sBAAsB,CAAC,MAAM,CAAC,CAKhC"}
|