@celljs/oauth2-client 3.7.8 → 3.9.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/esm/node/authentication/authentication-protocol.d.ts +24 -0
- package/esm/node/authentication/authentication-protocol.js +8 -0
- package/esm/node/authentication/authentication-protocol.js.map +1 -0
- package/esm/node/authentication/index.d.ts +3 -0
- package/esm/node/authentication/index.js +4 -0
- package/esm/node/authentication/index.js.map +1 -0
- package/esm/node/authentication/oauth2-authentication-provider.d.ts +29 -0
- package/esm/node/authentication/oauth2-authentication-provider.js +167 -0
- package/esm/node/authentication/oauth2-authentication-provider.js.map +1 -0
- package/esm/node/authentication/oidc-authentication-provider.d.ts +17 -0
- package/esm/node/authentication/oidc-authentication-provider.js +71 -0
- package/esm/node/authentication/oidc-authentication-provider.js.map +1 -0
- package/esm/node/authorization/authorization-code-authorized-client-provider.d.ts +4 -0
- package/esm/node/authorization/authorization-code-authorized-client-provider.js +24 -0
- package/esm/node/authorization/authorization-code-authorized-client-provider.js.map +1 -0
- package/esm/node/authorization/authorization-code-grant-middleware.d.ts +25 -0
- package/esm/node/authorization/authorization-code-grant-middleware.js +126 -0
- package/esm/node/authorization/authorization-code-grant-middleware.js.map +1 -0
- package/esm/node/authorization/authorization-failure-handler.d.ts +9 -0
- package/esm/node/authorization/authorization-failure-handler.js +32 -0
- package/esm/node/authorization/authorization-failure-handler.js.map +1 -0
- package/esm/node/authorization/authorization-protocol.d.ts +77 -0
- package/esm/node/authorization/authorization-protocol.js +31 -0
- package/esm/node/authorization/authorization-protocol.js.map +1 -0
- package/esm/node/authorization/authorization-request-manager.d.ts +12 -0
- package/esm/node/authorization/authorization-request-manager.js +61 -0
- package/esm/node/authorization/authorization-request-manager.js.map +1 -0
- package/esm/node/authorization/authorization-request-redirect-middleware.d.ts +19 -0
- package/esm/node/authorization/authorization-request-redirect-middleware.js +110 -0
- package/esm/node/authorization/authorization-request-redirect-middleware.js.map +1 -0
- package/esm/node/authorization/authorization-request-resolver.d.ts +37 -0
- package/esm/node/authorization/authorization-request-resolver.js +153 -0
- package/esm/node/authorization/authorization-request-resolver.js.map +1 -0
- package/esm/node/authorization/authorization-success-handler.d.ts +6 -0
- package/esm/node/authorization/authorization-success-handler.js +25 -0
- package/esm/node/authorization/authorization-success-handler.js.map +1 -0
- package/esm/node/authorization/authorized-client-manager.d.ts +10 -0
- package/esm/node/authorization/authorized-client-manager.js +45 -0
- package/esm/node/authorization/authorized-client-manager.js.map +1 -0
- package/esm/node/authorization/authorized-client-service.d.ts +11 -0
- package/esm/node/authorization/authorized-client-service.js +84 -0
- package/esm/node/authorization/authorized-client-service.js.map +1 -0
- package/esm/node/authorization/client-credentials-authorized-client-provider.d.ts +11 -0
- package/esm/node/authorization/client-credentials-authorized-client-provider.js +69 -0
- package/esm/node/authorization/client-credentials-authorized-client-provider.js.map +1 -0
- package/esm/node/authorization/context-attributes-mapper.d.ts +4 -0
- package/esm/node/authorization/context-attributes-mapper.js +25 -0
- package/esm/node/authorization/context-attributes-mapper.js.map +1 -0
- package/esm/node/authorization/index.d.ts +13 -0
- package/esm/node/authorization/index.js +14 -0
- package/esm/node/authorization/index.js.map +1 -0
- package/esm/node/authorization/password-authorized-client-provider.d.ts +11 -0
- package/esm/node/authorization/password-authorized-client-provider.js +82 -0
- package/esm/node/authorization/password-authorized-client-provider.js.map +1 -0
- package/esm/node/authorization/refresh-token-authorized-client-provider.d.ts +11 -0
- package/esm/node/authorization/refresh-token-authorized-client-provider.js +65 -0
- package/esm/node/authorization/refresh-token-authorized-client-provider.js.map +1 -0
- package/esm/node/constants.d.ts +4 -0
- package/esm/node/constants.js +5 -0
- package/esm/node/constants.js.map +1 -0
- package/esm/node/endpoint/authorization-code-token-response-client.d.ts +11 -0
- package/esm/node/endpoint/authorization-code-token-response-client.js +80 -0
- package/esm/node/endpoint/authorization-code-token-response-client.js.map +1 -0
- package/esm/node/endpoint/client-credentials-token-response-client.d.ts +11 -0
- package/esm/node/endpoint/client-credentials-token-response-client.js +77 -0
- package/esm/node/endpoint/client-credentials-token-response-client.js.map +1 -0
- package/esm/node/endpoint/endpoint-protocol.d.ts +47 -0
- package/esm/node/endpoint/endpoint-protocol.js +6 -0
- package/esm/node/endpoint/endpoint-protocol.js.map +1 -0
- package/esm/node/endpoint/index.d.ts +6 -0
- package/esm/node/endpoint/index.js +7 -0
- package/esm/node/endpoint/index.js.map +1 -0
- package/esm/node/endpoint/password-token-response-client.d.ts +11 -0
- package/esm/node/endpoint/password-token-response-client.js +79 -0
- package/esm/node/endpoint/password-token-response-client.js.map +1 -0
- package/esm/node/endpoint/refresh-token-token-response-client.d.ts +11 -0
- package/esm/node/endpoint/refresh-token-token-response-client.js +84 -0
- package/esm/node/endpoint/refresh-token-token-response-client.js.map +1 -0
- package/esm/node/endpoint/user-response-client.d.ts +8 -0
- package/esm/node/endpoint/user-response-client.js +81 -0
- package/esm/node/endpoint/user-response-client.js.map +1 -0
- package/esm/node/error/error-handler.d.ts +10 -0
- package/esm/node/error/error-handler.js +50 -0
- package/esm/node/error/error-handler.js.map +1 -0
- package/esm/node/error/error-protocol.d.ts +2 -0
- package/esm/node/error/error-protocol.js +4 -0
- package/esm/node/error/error-protocol.js.map +1 -0
- package/esm/node/error/error.d.ts +9 -0
- package/esm/node/error/error.js +18 -0
- package/esm/node/error/error.js.map +1 -0
- package/esm/node/error/index.d.ts +3 -0
- package/esm/node/error/index.js +4 -0
- package/esm/node/error/index.js.map +1 -0
- package/esm/node/index.d.ts +7 -0
- package/esm/node/index.js +8 -0
- package/esm/node/index.js.map +1 -0
- package/esm/node/module.d.ts +3 -0
- package/esm/node/module.js +4 -0
- package/esm/node/module.js.map +1 -0
- package/esm/node/provider/index.d.ts +2 -0
- package/esm/node/provider/index.js +3 -0
- package/esm/node/provider/index.js.map +1 -0
- package/esm/node/provider/provider-details-manager.d.ts +11 -0
- package/esm/node/provider/provider-details-manager.js +47 -0
- package/esm/node/provider/provider-details-manager.js.map +1 -0
- package/esm/node/provider/provider-protocol.d.ts +20 -0
- package/esm/node/provider/provider-protocol.js +2 -0
- package/esm/node/provider/provider-protocol.js.map +1 -0
- package/esm/node/registration/id-token-jwt-decoder-facatory.d.ts +14 -0
- package/esm/node/registration/id-token-jwt-decoder-facatory.js +86 -0
- package/esm/node/registration/id-token-jwt-decoder-facatory.js.map +1 -0
- package/esm/node/registration/index.d.ts +4 -0
- package/esm/node/registration/index.js +5 -0
- package/esm/node/registration/index.js.map +1 -0
- package/esm/node/registration/jws-algorithm-resolver.d.ts +4 -0
- package/esm/node/registration/jws-algorithm-resolver.js +19 -0
- package/esm/node/registration/jws-algorithm-resolver.js.map +1 -0
- package/esm/node/registration/registration-manager.d.ts +14 -0
- package/esm/node/registration/registration-manager.js +61 -0
- package/esm/node/registration/registration-manager.js.map +1 -0
- package/esm/node/registration/registration-protocol.d.ts +21 -0
- package/esm/node/registration/registration-protocol.js +4 -0
- package/esm/node/registration/registration-protocol.js.map +1 -0
- package/esm/node/user/index.d.ts +3 -0
- package/esm/node/user/index.js +4 -0
- package/esm/node/user/index.js.map +1 -0
- package/esm/node/user/oauth2-user-service.d.ts +9 -0
- package/esm/node/user/oauth2-user-service.js +58 -0
- package/esm/node/user/oauth2-user-service.js.map +1 -0
- package/esm/node/user/oidc-user-service.d.ts +12 -0
- package/esm/node/user/oidc-user-service.js +95 -0
- package/esm/node/user/oidc-user-service.js.map +1 -0
- package/esm/node/user/user-protocol.d.ts +5 -0
- package/esm/node/user/user-protocol.js +2 -0
- package/esm/node/user/user-protocol.js.map +1 -0
- package/esm/node/utils/authorization-grant-request-entity-util.d.ts +9 -0
- package/esm/node/utils/authorization-grant-request-entity-util.js +26 -0
- package/esm/node/utils/authorization-grant-request-entity-util.js.map +1 -0
- package/esm/node/utils/authorization-response-util.d.ts +7 -0
- package/esm/node/utils/authorization-response-util.js +50 -0
- package/esm/node/utils/authorization-response-util.js.map +1 -0
- package/esm/node/utils/index.d.ts +2 -0
- package/esm/node/utils/index.js +3 -0
- package/esm/node/utils/index.js.map +1 -0
- package/esm/package.json +3 -0
- package/lib/node/authentication/authentication-protocol.js.map +1 -1
- package/lib/node/authentication/oauth2-authentication-provider.d.ts.map +1 -1
- package/lib/node/authentication/oauth2-authentication-provider.js.map +1 -1
- package/lib/node/authentication/oidc-authentication-provider.d.ts.map +1 -1
- package/lib/node/authentication/oidc-authentication-provider.js.map +1 -1
- package/lib/node/authorization/authorization-code-authorized-client-provider.d.ts.map +1 -1
- package/lib/node/authorization/authorization-code-authorized-client-provider.js.map +1 -1
- package/lib/node/authorization/authorization-code-grant-middleware.d.ts.map +1 -1
- package/lib/node/authorization/authorization-code-grant-middleware.js.map +1 -1
- package/lib/node/authorization/authorization-failure-handler.d.ts.map +1 -1
- package/lib/node/authorization/authorization-failure-handler.js.map +1 -1
- package/lib/node/authorization/authorization-protocol.js.map +1 -1
- package/lib/node/authorization/authorization-request-manager.d.ts.map +1 -1
- package/lib/node/authorization/authorization-request-manager.js.map +1 -1
- package/lib/node/authorization/authorization-request-redirect-middleware.d.ts.map +1 -1
- package/lib/node/authorization/authorization-request-redirect-middleware.js.map +1 -1
- package/lib/node/authorization/authorization-request-resolver.d.ts.map +1 -1
- package/lib/node/authorization/authorization-request-resolver.js +34 -1
- package/lib/node/authorization/authorization-request-resolver.js.map +1 -1
- package/lib/node/authorization/authorization-success-handler.d.ts.map +1 -1
- package/lib/node/authorization/authorization-success-handler.js.map +1 -1
- package/lib/node/authorization/authorized-client-manager.d.ts.map +1 -1
- package/lib/node/authorization/authorized-client-manager.js.map +1 -1
- package/lib/node/authorization/authorized-client-service.d.ts.map +1 -1
- package/lib/node/authorization/authorized-client-service.js.map +1 -1
- package/lib/node/authorization/client-credentials-authorized-client-provider.d.ts.map +1 -1
- package/lib/node/authorization/client-credentials-authorized-client-provider.js.map +1 -1
- package/lib/node/authorization/context-attributes-mapper.d.ts.map +1 -1
- package/lib/node/authorization/context-attributes-mapper.js.map +1 -1
- package/lib/node/authorization/password-authorized-client-provider.d.ts.map +1 -1
- package/lib/node/authorization/password-authorized-client-provider.js.map +1 -1
- package/lib/node/authorization/refresh-token-authorized-client-provider.d.ts.map +1 -1
- package/lib/node/authorization/refresh-token-authorized-client-provider.js.map +1 -1
- package/lib/node/endpoint/authorization-code-token-response-client.d.ts.map +1 -1
- package/lib/node/endpoint/authorization-code-token-response-client.js +34 -1
- package/lib/node/endpoint/authorization-code-token-response-client.js.map +1 -1
- package/lib/node/endpoint/client-credentials-token-response-client.d.ts.map +1 -1
- package/lib/node/endpoint/client-credentials-token-response-client.js +34 -1
- package/lib/node/endpoint/client-credentials-token-response-client.js.map +1 -1
- package/lib/node/endpoint/password-token-response-client.d.ts.map +1 -1
- package/lib/node/endpoint/password-token-response-client.js +34 -1
- package/lib/node/endpoint/password-token-response-client.js.map +1 -1
- package/lib/node/endpoint/refresh-token-token-response-client.d.ts.map +1 -1
- package/lib/node/endpoint/refresh-token-token-response-client.js +34 -1
- package/lib/node/endpoint/refresh-token-token-response-client.js.map +1 -1
- package/lib/node/endpoint/user-response-client.d.ts.map +1 -1
- package/lib/node/endpoint/user-response-client.js +34 -1
- package/lib/node/endpoint/user-response-client.js.map +1 -1
- package/lib/node/error/error-handler.d.ts.map +1 -1
- package/lib/node/error/error-handler.js.map +1 -1
- package/lib/node/error/error.d.ts.map +1 -1
- package/lib/node/error/error.js.map +1 -1
- package/lib/node/module.d.ts.map +1 -1
- package/lib/node/module.js.map +1 -1
- package/lib/node/provider/provider-details-manager.d.ts.map +1 -1
- package/lib/node/provider/provider-details-manager.js.map +1 -1
- package/lib/node/registration/id-token-jwt-decoder-facatory.d.ts.map +1 -1
- package/lib/node/registration/id-token-jwt-decoder-facatory.js.map +1 -1
- package/lib/node/registration/jws-algorithm-resolver.d.ts.map +1 -1
- package/lib/node/registration/jws-algorithm-resolver.js.map +1 -1
- package/lib/node/registration/registration-manager.d.ts.map +1 -1
- package/lib/node/registration/registration-manager.js.map +1 -1
- package/lib/node/user/oauth2-user-service.d.ts.map +1 -1
- package/lib/node/user/oauth2-user-service.js.map +1 -1
- package/lib/node/user/oidc-user-service.d.ts.map +1 -1
- package/lib/node/user/oidc-user-service.js.map +1 -1
- package/lib/node/utils/authorization-grant-request-entity-util.js.map +1 -1
- package/lib/node/utils/authorization-response-util.js.map +1 -1
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.js +5 -2
- package/lib/package.spec.js.map +1 -1
- package/package.json +76 -14
- package/src/package.spec.ts +1 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Authentication } from '@celljs/security/lib/node';
|
|
2
|
+
import { ClientRegistration } from '../registration/index.js';
|
|
3
|
+
import { AuthorizationExchange, AccessToken, RefreshToken } from '@celljs/oauth2-core';
|
|
4
|
+
export declare const INVALID_ID_TOKEN_ERROR_CODE = "invalid_id_token";
|
|
5
|
+
export declare const INVALID_NONCE_ERROR_CODE = "invalid_nonce";
|
|
6
|
+
export declare const AUTHORIZATION_REQUEST_NOT_FOUND_ERROR_CODE = "authorization_request_not_found";
|
|
7
|
+
export declare const CLIENT_REGISTRATION_NOT_FOUND_ERROR_CODE = "client_registration_not_found";
|
|
8
|
+
export declare const OAUTH2_AUTHENTICATION_PROVIDER_PRIORITY: number;
|
|
9
|
+
export declare const OIDC_AUTHENTICATION_PROVIDER_PRIORITY: number;
|
|
10
|
+
export interface OAuth2LoginAuthentication extends Authentication {
|
|
11
|
+
clientRegistration: ClientRegistration;
|
|
12
|
+
authorizationExchange: AuthorizationExchange;
|
|
13
|
+
accessToken: AccessToken;
|
|
14
|
+
refreshToken?: RefreshToken;
|
|
15
|
+
}
|
|
16
|
+
export interface OAuth2AuthorizationCodeAuthentication extends Authentication {
|
|
17
|
+
clientRegistration: ClientRegistration;
|
|
18
|
+
authorizationExchange: AuthorizationExchange;
|
|
19
|
+
accessToken: AccessToken;
|
|
20
|
+
refreshToken?: RefreshToken;
|
|
21
|
+
additionalParameters: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY } from '@celljs/security/lib/node';
|
|
2
|
+
export const INVALID_ID_TOKEN_ERROR_CODE = 'invalid_id_token';
|
|
3
|
+
export const INVALID_NONCE_ERROR_CODE = 'invalid_nonce';
|
|
4
|
+
export const AUTHORIZATION_REQUEST_NOT_FOUND_ERROR_CODE = 'authorization_request_not_found';
|
|
5
|
+
export const CLIENT_REGISTRATION_NOT_FOUND_ERROR_CODE = 'client_registration_not_found';
|
|
6
|
+
export const OAUTH2_AUTHENTICATION_PROVIDER_PRIORITY = USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY + 100;
|
|
7
|
+
export const OIDC_AUTHENTICATION_PROVIDER_PRIORITY = OAUTH2_AUTHENTICATION_PROVIDER_PRIORITY + 100;
|
|
8
|
+
//# sourceMappingURL=authentication-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-protocol.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,kDAAkD,EAAE,MAAM,2BAA2B,CAAC;AAI/G,MAAM,CAAC,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,0CAA0C,GAAG,iCAAiC,CAAC;AAC5F,MAAM,CAAC,MAAM,wCAAwC,GAAG,+BAA+B,CAAC;AAExF,MAAM,CAAC,MAAM,uCAAuC,GAAG,kDAAkD,GAAG,GAAG,CAAC;AAChH,MAAM,CAAC,MAAM,qCAAqC,GAAG,uCAAuC,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/authentication/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RequestMatcher } from '@celljs/web/lib/node';
|
|
2
|
+
import { PathResolver } from '@celljs/web';
|
|
3
|
+
import { AuthorizationRequest, AccessTokenResponse } from '@celljs/oauth2-core';
|
|
4
|
+
import { AuthorizationRequestManager, AuthorizedClientManager, AuthorizedClient } from '../authorization/index.js';
|
|
5
|
+
import { ClientRegistration, ClientRegistrationManager } from '../registration/index.js';
|
|
6
|
+
import { AuthorizationCodeTokenResponseClient, OAuth2UserRequest } from '../endpoint/index.js';
|
|
7
|
+
import { AuthenticationProvider, UserChecker, UserService, UserMapper } from '@celljs/security/lib/node';
|
|
8
|
+
import { User } from '@celljs/security';
|
|
9
|
+
import { OAuth2LoginAuthentication } from './authentication-protocol.js';
|
|
10
|
+
export declare class OAuth2AuthenticationProvider implements AuthenticationProvider {
|
|
11
|
+
protected readonly options: any;
|
|
12
|
+
protected readonly authorizationRequestManager: AuthorizationRequestManager<AuthorizationRequest>;
|
|
13
|
+
protected readonly clientRegistrationManager: ClientRegistrationManager;
|
|
14
|
+
protected readonly authorizedClientManager: AuthorizedClientManager<AuthorizedClient>;
|
|
15
|
+
protected readonly userService: UserService<OAuth2UserRequest, User>;
|
|
16
|
+
protected readonly userChecker: UserChecker;
|
|
17
|
+
protected readonly userMapper: UserMapper;
|
|
18
|
+
protected readonly authorizationCodeTokenResponseClient: AuthorizationCodeTokenResponseClient;
|
|
19
|
+
protected readonly requestMatcher: RequestMatcher;
|
|
20
|
+
protected readonly pathResolver: PathResolver;
|
|
21
|
+
protected readonly endpoint: string;
|
|
22
|
+
priority: number;
|
|
23
|
+
protected checkScopes(scopes: string[]): boolean;
|
|
24
|
+
protected getUserinfo(clientRegistration: ClientRegistration, tokenResponse: AccessTokenResponse, additionalParameters: {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
}): Promise<User>;
|
|
27
|
+
authenticate(): Promise<OAuth2LoginAuthentication | undefined>;
|
|
28
|
+
support(): Promise<boolean>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, Autowired, Value } from '@celljs/core';
|
|
11
|
+
import { Context, RequestMatcher } from '@celljs/web/lib/node';
|
|
12
|
+
import { PathResolver, ENDPOINT } from '@celljs/web';
|
|
13
|
+
import { AuthorizationResponseUtil } from '../utils/index.js';
|
|
14
|
+
import { OAuth2AuthenticationError, OAuth2ParameterNames, OAuth2AuthorizationError, OAuth2ErrorCodes, OidcScopes } from '@celljs/oauth2-core';
|
|
15
|
+
import { AuthorizationRequestManager, AuthorizedClientManager, INVALID_STATE_PARAMETER_ERROR_CODE } from '../authorization/index.js';
|
|
16
|
+
import { ClientRegistrationManager } from '../registration/index.js';
|
|
17
|
+
import { AuthorizationCodeTokenResponseClient } from '../endpoint/index.js';
|
|
18
|
+
import { AuthenticationProvider, UserChecker, UserService, UserMapper } from '@celljs/security/lib/node';
|
|
19
|
+
import { OAUTH2_AUTHENTICATION_PROVIDER_PRIORITY, AUTHORIZATION_REQUEST_NOT_FOUND_ERROR_CODE, CLIENT_REGISTRATION_NOT_FOUND_ERROR_CODE } from './authentication-protocol.js';
|
|
20
|
+
import { OAuth2UserService } from '../user/index.js';
|
|
21
|
+
let OAuth2AuthenticationProvider = class OAuth2AuthenticationProvider {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.priority = OAUTH2_AUTHENTICATION_PROVIDER_PRIORITY;
|
|
24
|
+
}
|
|
25
|
+
checkScopes(scopes) {
|
|
26
|
+
// Section 3.1.2.1 Authentication Request -
|
|
27
|
+
// https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest scope
|
|
28
|
+
// REQUIRED. OpenID Connect requests MUST contain the "openid" scope value.
|
|
29
|
+
if (scopes.indexOf(OidcScopes.OPENID) !== -1) {
|
|
30
|
+
// This is an OpenID Connect Authentication Request so return null
|
|
31
|
+
// and let OidcAuthorizationCodeAuthenticationProvider handle it instead
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
getUserinfo(clientRegistration, tokenResponse, additionalParameters) {
|
|
37
|
+
return this.userService.load({
|
|
38
|
+
clientRegistration,
|
|
39
|
+
accessToken: tokenResponse.accessToken,
|
|
40
|
+
additionalParameters
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async authenticate() {
|
|
44
|
+
if (!AuthorizationResponseUtil.isAuthorizationResponse()) {
|
|
45
|
+
throw new OAuth2AuthenticationError({
|
|
46
|
+
errorCode: OAuth2ErrorCodes.INVALID_REQUEST
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const authorizationRequest = await this.authorizationRequestManager.get();
|
|
50
|
+
if (!authorizationRequest) {
|
|
51
|
+
throw new OAuth2AuthenticationError({
|
|
52
|
+
errorCode: AUTHORIZATION_REQUEST_NOT_FOUND_ERROR_CODE
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!this.checkScopes(authorizationRequest.scopes)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const registrationId = authorizationRequest.attributes[OAuth2ParameterNames.REGISTRATION_ID];
|
|
59
|
+
const clientRegistration = await this.clientRegistrationManager.get(registrationId);
|
|
60
|
+
if (!clientRegistration) {
|
|
61
|
+
throw new OAuth2AuthenticationError({
|
|
62
|
+
errorCode: CLIENT_REGISTRATION_NOT_FOUND_ERROR_CODE,
|
|
63
|
+
description: `Client Registration not found with Id: ${registrationId}`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const redirectUri = await this.pathResolver.resolve(this.endpoint, Context.getRequest().path);
|
|
67
|
+
const authorizationResponse = AuthorizationResponseUtil.convert(redirectUri);
|
|
68
|
+
if (authorizationResponse.error) {
|
|
69
|
+
throw new OAuth2AuthenticationError(authorizationResponse.error);
|
|
70
|
+
}
|
|
71
|
+
if (authorizationResponse.state !== authorizationRequest.state) {
|
|
72
|
+
throw new OAuth2AuthenticationError({
|
|
73
|
+
errorCode: INVALID_STATE_PARAMETER_ERROR_CODE
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
let tokenResponse;
|
|
77
|
+
try {
|
|
78
|
+
tokenResponse = await this.authorizationCodeTokenResponseClient.getTokenResponse({
|
|
79
|
+
authorizationGrantType: clientRegistration.authorizationGrantType,
|
|
80
|
+
clientRegistration,
|
|
81
|
+
authorizationExchange: {
|
|
82
|
+
authorizationRequest, authorizationResponse
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (error instanceof OAuth2AuthorizationError) {
|
|
88
|
+
throw new OAuth2AuthenticationError(error.oauth2Error);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
const { additionalParameters } = tokenResponse;
|
|
93
|
+
const user = await this.getUserinfo(clientRegistration, tokenResponse, additionalParameters);
|
|
94
|
+
await this.userChecker.check(user);
|
|
95
|
+
await this.userMapper.map(user);
|
|
96
|
+
await this.authorizedClientManager.save({
|
|
97
|
+
clientRegistration,
|
|
98
|
+
accessToken: tokenResponse.accessToken,
|
|
99
|
+
refreshToken: tokenResponse.refreshToken,
|
|
100
|
+
principalName: user.username
|
|
101
|
+
}, user.username);
|
|
102
|
+
await this.authorizationRequestManager.remove();
|
|
103
|
+
return {
|
|
104
|
+
name: user.username,
|
|
105
|
+
principal: user,
|
|
106
|
+
credentials: '',
|
|
107
|
+
policies: user.policies,
|
|
108
|
+
clientRegistration,
|
|
109
|
+
authorizationExchange: { authorizationRequest, authorizationResponse },
|
|
110
|
+
accessToken: tokenResponse.accessToken,
|
|
111
|
+
refreshToken: tokenResponse.refreshToken,
|
|
112
|
+
authenticated: true
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async support() {
|
|
116
|
+
return !!await this.requestMatcher.match(await this.pathResolver.resolve(this.options.redirectLoginPath));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
__decorate([
|
|
120
|
+
Value('cell.oauth2.client'),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], OAuth2AuthenticationProvider.prototype, "options", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
Autowired(AuthorizationRequestManager),
|
|
125
|
+
__metadata("design:type", Object)
|
|
126
|
+
], OAuth2AuthenticationProvider.prototype, "authorizationRequestManager", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
Autowired(ClientRegistrationManager),
|
|
129
|
+
__metadata("design:type", Object)
|
|
130
|
+
], OAuth2AuthenticationProvider.prototype, "clientRegistrationManager", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
Autowired(AuthorizedClientManager),
|
|
133
|
+
__metadata("design:type", Object)
|
|
134
|
+
], OAuth2AuthenticationProvider.prototype, "authorizedClientManager", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
Autowired(OAuth2UserService),
|
|
137
|
+
__metadata("design:type", Object)
|
|
138
|
+
], OAuth2AuthenticationProvider.prototype, "userService", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
Autowired(UserChecker),
|
|
141
|
+
__metadata("design:type", Object)
|
|
142
|
+
], OAuth2AuthenticationProvider.prototype, "userChecker", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
Autowired(UserMapper),
|
|
145
|
+
__metadata("design:type", Object)
|
|
146
|
+
], OAuth2AuthenticationProvider.prototype, "userMapper", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
Autowired(AuthorizationCodeTokenResponseClient),
|
|
149
|
+
__metadata("design:type", AuthorizationCodeTokenResponseClient)
|
|
150
|
+
], OAuth2AuthenticationProvider.prototype, "authorizationCodeTokenResponseClient", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
Autowired(RequestMatcher),
|
|
153
|
+
__metadata("design:type", Object)
|
|
154
|
+
], OAuth2AuthenticationProvider.prototype, "requestMatcher", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
Autowired(PathResolver),
|
|
157
|
+
__metadata("design:type", Object)
|
|
158
|
+
], OAuth2AuthenticationProvider.prototype, "pathResolver", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
Value(ENDPOINT),
|
|
161
|
+
__metadata("design:type", String)
|
|
162
|
+
], OAuth2AuthenticationProvider.prototype, "endpoint", void 0);
|
|
163
|
+
OAuth2AuthenticationProvider = __decorate([
|
|
164
|
+
Component(AuthenticationProvider)
|
|
165
|
+
], OAuth2AuthenticationProvider);
|
|
166
|
+
export { OAuth2AuthenticationProvider };
|
|
167
|
+
//# sourceMappingURL=oauth2-authentication-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2-authentication-provider.js","sourceRoot":"","sources":["../../../src/node/authentication/oauth2-authentication-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;A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AC,WAAW;YACtC,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,aAAa,EAAE,IAAI;SACtB,CAAC;IAEN,CAAC;IAED,KAAK,CAAC,OAAO;QACT,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC9G,CAAC;CAEJ,CAAA;AA9IsB;IADlB,KAAK,CAAC,oBAAoB,CAAC;;6DACI;AAGb;IADlB,SAAS,CAAC,2BAA2B,CAAC;;iFAC2D;AAG/E;IADlB,SAAS,CAAC,yBAAyB,CAAC;;+EACmC;AAGrD;IADlB,SAAS,CAAC,uBAAuB,CAAC;;6EACmD;AAGnE;IADlB,SAAS,CAAC,iBAAiB,CAAC;;iEACwC;AAGlD;IADlB,SAAS,CAAC,WAAW,CAAC;;iEACqB;AAGzB;IADlB,SAAS,CAAC,UAAU,CAAC;;gEACoB;AAGvB;IADlB,SAAS,CAAC,oCAAoC,CAAC;8BACS,oCAAoC;0FAAC;AAG3E;IADlB,SAAS,CAAC,cAAc,CAAC;;oEACwB;AAG/B;IADlB,SAAS,CAAC,YAAY,CAAC;;kEACsB;AAG3B;IADlB,KAAK,CAAC,QAAQ,CAAC;;8DACoB;AAjC3B,4BAA4B;IADxC,SAAS,CAAC,sBAAsB,CAAC;GACrB,4BAA4B,CAiJxC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AccessTokenResponse } from '@celljs/oauth2-core';
|
|
2
|
+
import { IdTokenJwtDecoderFactory, ClientRegistration } from '../registration/index.js';
|
|
3
|
+
import { Jwt } from '@celljs/oauth2-jose';
|
|
4
|
+
import { OidcUserRequest } from '../user/index.js';
|
|
5
|
+
import { UserService } from '@celljs/security/lib/node';
|
|
6
|
+
import { User } from '@celljs/security';
|
|
7
|
+
import { OAuth2AuthenticationProvider } from './oauth2-authentication-provider.js';
|
|
8
|
+
export declare class OidcAuthenticationProvider extends OAuth2AuthenticationProvider {
|
|
9
|
+
protected readonly idTokenJwtDecoderFactory: IdTokenJwtDecoderFactory;
|
|
10
|
+
protected readonly userService: UserService<OidcUserRequest, User>;
|
|
11
|
+
priority: number;
|
|
12
|
+
protected checkScopes(scopes: string[]): boolean;
|
|
13
|
+
protected getUserinfo(clientRegistration: ClientRegistration, tokenResponse: AccessTokenResponse, additionalParameters: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
}): Promise<User>;
|
|
16
|
+
protected createOidcToken(clientRegistration: ClientRegistration, tokenResponse: AccessTokenResponse): Promise<Jwt>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, Autowired } from '@celljs/core';
|
|
11
|
+
import { OAuth2AuthenticationError, OidcScopes, OidcParameterNames } from '@celljs/oauth2-core';
|
|
12
|
+
import { IdTokenJwtDecoderFactory } from '../registration/index.js';
|
|
13
|
+
import { errors } from 'jose';
|
|
14
|
+
import { OidcUserService } from '../user/index.js';
|
|
15
|
+
import { UserService, AuthenticationProvider } from '@celljs/security/lib/node';
|
|
16
|
+
import { OIDC_AUTHENTICATION_PROVIDER_PRIORITY, INVALID_ID_TOKEN_ERROR_CODE } from './authentication-protocol.js';
|
|
17
|
+
import { OAuth2AuthenticationProvider } from './oauth2-authentication-provider.js';
|
|
18
|
+
let OidcAuthenticationProvider = class OidcAuthenticationProvider extends OAuth2AuthenticationProvider {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.priority = OIDC_AUTHENTICATION_PROVIDER_PRIORITY;
|
|
22
|
+
}
|
|
23
|
+
checkScopes(scopes) {
|
|
24
|
+
// Section 3.1.2.1 Authentication Request - https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
|
|
25
|
+
// scope
|
|
26
|
+
// REQUIRED. OpenID Connect requests MUST contain the "openid" scope value.
|
|
27
|
+
if (scopes.indexOf(OidcScopes.OPENID) === -1) {
|
|
28
|
+
// This is NOT an OpenID Connect Authentication Request so return undefined
|
|
29
|
+
// and let OAuth2AuthenticationProvider handle it instead
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
async getUserinfo(clientRegistration, tokenResponse, additionalParameters) {
|
|
35
|
+
const idToken = await this.createOidcToken(clientRegistration, tokenResponse);
|
|
36
|
+
return this.userService.load({
|
|
37
|
+
idToken,
|
|
38
|
+
clientRegistration,
|
|
39
|
+
accessToken: tokenResponse.accessToken,
|
|
40
|
+
additionalParameters
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async createOidcToken(clientRegistration, tokenResponse) {
|
|
44
|
+
const jwtDecoder = await this.idTokenJwtDecoderFactory.create(clientRegistration);
|
|
45
|
+
try {
|
|
46
|
+
return jwtDecoder.decode(tokenResponse.additionalParameters[OidcParameterNames.ID_TOKEN]);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof errors.JOSEError) {
|
|
50
|
+
throw new OAuth2AuthenticationError({
|
|
51
|
+
errorCode: INVALID_ID_TOKEN_ERROR_CODE,
|
|
52
|
+
description: error.message
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
__decorate([
|
|
60
|
+
Autowired(IdTokenJwtDecoderFactory),
|
|
61
|
+
__metadata("design:type", IdTokenJwtDecoderFactory)
|
|
62
|
+
], OidcAuthenticationProvider.prototype, "idTokenJwtDecoderFactory", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
Autowired(OidcUserService),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], OidcAuthenticationProvider.prototype, "userService", void 0);
|
|
67
|
+
OidcAuthenticationProvider = __decorate([
|
|
68
|
+
Component(AuthenticationProvider)
|
|
69
|
+
], OidcAuthenticationProvider);
|
|
70
|
+
export { OidcAuthenticationProvider };
|
|
71
|
+
//# sourceMappingURL=oidc-authentication-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oidc-authentication-provider.js","sourceRoot":"","sources":["../../../src/node/authentication/oidc-authentication-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,UAAU,EAAuB,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AACpH,OAAO,EAAE,wBAAwB,EAAsB,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAmB,eAAe,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,EAAE,qCAAqC,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC/G,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAGzE,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,4BAA4B;IAArE;;QAQM,aAAQ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S,CAAC,eAAe,CAAC;;+DACiD;AANnE,0BAA0B;IADtC,SAAS,CAAC,sBAAsB,CAAC;GACrB,0BAA0B,CA+CtC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuthorizedClientProvider, AuthorizationContext, AuthorizedClient } from './authorization-protocol.js';
|
|
2
|
+
export declare class AuthorizationCodeAuthorizedClientProvider implements AuthorizedClientProvider {
|
|
3
|
+
provide(context: AuthorizationContext): Promise<AuthorizedClient | undefined>;
|
|
4
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { AuthorizedClientProvider } from './authorization-protocol.js';
|
|
8
|
+
import { AuthorizationGrantType } from '@celljs/oauth2-core';
|
|
9
|
+
import { ClientAuthorizationRequiredError } from '../error/index.js';
|
|
10
|
+
import { Component } from '@celljs/core';
|
|
11
|
+
let AuthorizationCodeAuthorizedClientProvider = class AuthorizationCodeAuthorizedClientProvider {
|
|
12
|
+
async provide(context) {
|
|
13
|
+
const { clientRegistration, authorizedClient } = context;
|
|
14
|
+
if (AuthorizationGrantType.AuthorizationCode === clientRegistration.authorizationGrantType && !authorizedClient) {
|
|
15
|
+
throw new ClientAuthorizationRequiredError(clientRegistration.registrationId);
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
AuthorizationCodeAuthorizedClientProvider = __decorate([
|
|
21
|
+
Component(AuthorizedClientProvider)
|
|
22
|
+
], AuthorizationCodeAuthorizedClientProvider);
|
|
23
|
+
export { AuthorizationCodeAuthorizedClientProvider };
|
|
24
|
+
//# sourceMappingURL=authorization-code-authorized-client-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-code-authorized-client-provider.js","sourceRoot":"","sources":["../../../src/node/authorization/authorization-code-authorized-client-provider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,wBAAwB,EAA0C,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,yCAAyC,GAA/C,MAAM,yCAAyC;IAClD,KAAK,CAAC,OAAO,CAAC,OAA6B;QACvC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;QACzD,IAAI,sBAAsB,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,sBAAsB,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9G,MAAM,IAAI,gCAAgC,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAClF,CAAC;QACD,OAAO;IACX,CAAC;CAEJ,CAAA;AATY,yCAAyC;IADrD,SAAS,CAAC,wBAAwB,CAAC;GACvB,yCAAyC,CASrD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Middleware, Context, RedirectStrategy, RequestMatcher } from '@celljs/web/lib/node';
|
|
2
|
+
import { AuthorizationRequestResolver, AuthorizationRequestManager, AuthorizedClientManager, AuthorizedClient } from './authorization-protocol.js';
|
|
3
|
+
import { AuthorizationRequest } from '@celljs/oauth2-core';
|
|
4
|
+
import { ClientRegistrationManager } from '../registration/index.js';
|
|
5
|
+
import { PathResolver } from '@celljs/web';
|
|
6
|
+
import { RequestCache } from '@celljs/security/lib/node';
|
|
7
|
+
import { AuthorizationCodeTokenResponseClient } from '../endpoint/index.js';
|
|
8
|
+
export declare class AuthorizationCodeGrantMiddleware implements Middleware {
|
|
9
|
+
protected readonly authorizationRequestManager: AuthorizationRequestManager<AuthorizationRequest>;
|
|
10
|
+
protected readonly authorizationRequestResolver: AuthorizationRequestResolver;
|
|
11
|
+
protected readonly clientRegistrationManager: ClientRegistrationManager;
|
|
12
|
+
protected readonly authorizedClientManager: AuthorizedClientManager<AuthorizedClient>;
|
|
13
|
+
protected readonly redirectStrategy: RedirectStrategy;
|
|
14
|
+
protected readonly requestMatcher: RequestMatcher;
|
|
15
|
+
protected readonly pathResolver: PathResolver;
|
|
16
|
+
protected readonly requestCache: RequestCache;
|
|
17
|
+
protected readonly authorizationCodeTokenResponseClient: AuthorizationCodeTokenResponseClient;
|
|
18
|
+
protected readonly endpoint: string;
|
|
19
|
+
protected readonly redirectLoginPath: string;
|
|
20
|
+
protected readonly authorizationCodeGrantUri: string;
|
|
21
|
+
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
22
|
+
processAuthorizationResponse(): Promise<void>;
|
|
23
|
+
protected matchesAuthorizationResponse(): Promise<boolean>;
|
|
24
|
+
readonly priority: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Middleware, Context, RedirectStrategy, RequestMatcher } from '@celljs/web/lib/node';
|
|
11
|
+
import { Component, Value, Autowired } from '@celljs/core';
|
|
12
|
+
import { AuthorizationRequestResolver, AuthorizationRequestManager, AUTHORIZATION_CODE_GRANT_MIDDLEWARE_PRIORITY, AuthorizedClientManager, INVALID_STATE_PARAMETER_ERROR_CODE } from './authorization-protocol.js';
|
|
13
|
+
import { OAuth2ParameterNames, OAuth2AuthorizationError } from '@celljs/oauth2-core';
|
|
14
|
+
import { AuthorizationResponseUtil } from '../utils/index.js';
|
|
15
|
+
import { ClientRegistrationManager } from '../registration/index.js';
|
|
16
|
+
import { ENDPOINT, PathResolver } from '@celljs/web';
|
|
17
|
+
import { SecurityContext, RequestCache } from '@celljs/security/lib/node';
|
|
18
|
+
import { AuthorizationCodeTokenResponseClient } from '../endpoint/index.js';
|
|
19
|
+
import { AUTHORIZATION_CODE_GRANT_URI, REDIRECT_LOGIN_PATH } from '../constants.js';
|
|
20
|
+
let AuthorizationCodeGrantMiddleware = class AuthorizationCodeGrantMiddleware {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.priority = AUTHORIZATION_CODE_GRANT_MIDDLEWARE_PRIORITY;
|
|
23
|
+
}
|
|
24
|
+
async handle(ctx, next) {
|
|
25
|
+
if (await this.matchesAuthorizationResponse()) {
|
|
26
|
+
await this.processAuthorizationResponse();
|
|
27
|
+
}
|
|
28
|
+
await next();
|
|
29
|
+
}
|
|
30
|
+
async processAuthorizationResponse() {
|
|
31
|
+
const authorizationRequest = await this.authorizationRequestManager.remove();
|
|
32
|
+
const registrationId = authorizationRequest.attributes[OAuth2ParameterNames.REGISTRATION_ID];
|
|
33
|
+
const clientRegistration = await this.clientRegistrationManager.get(registrationId);
|
|
34
|
+
const redirectUri = await this.pathResolver.resolve(this.endpoint, Context.getRequest().path);
|
|
35
|
+
const authorizationResponse = AuthorizationResponseUtil.convert(redirectUri);
|
|
36
|
+
if (authorizationResponse.error) {
|
|
37
|
+
throw new OAuth2AuthorizationError(authorizationResponse.error);
|
|
38
|
+
}
|
|
39
|
+
if (authorizationResponse.state !== authorizationRequest.state) {
|
|
40
|
+
throw new OAuth2AuthorizationError({
|
|
41
|
+
errorCode: INVALID_STATE_PARAMETER_ERROR_CODE
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const tokenResponse = await this.authorizationCodeTokenResponseClient.getTokenResponse({
|
|
45
|
+
authorizationGrantType: clientRegistration.authorizationGrantType,
|
|
46
|
+
clientRegistration,
|
|
47
|
+
authorizationExchange: {
|
|
48
|
+
authorizationRequest, authorizationResponse
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const authentication = SecurityContext.getAuthentication();
|
|
52
|
+
const principalName = authentication.name;
|
|
53
|
+
await this.authorizedClientManager.save({
|
|
54
|
+
clientRegistration,
|
|
55
|
+
principalName,
|
|
56
|
+
accessToken: tokenResponse.accessToken,
|
|
57
|
+
refreshToken: tokenResponse.refreshToken
|
|
58
|
+
}, principalName);
|
|
59
|
+
const savedRequest = await this.requestCache.get();
|
|
60
|
+
await this.redirectStrategy.send((savedRequest === null || savedRequest === void 0 ? void 0 : savedRequest.redirectUrl) || authorizationRequest.redirectUri);
|
|
61
|
+
}
|
|
62
|
+
async matchesAuthorizationResponse() {
|
|
63
|
+
const authorizationMatch = this.authorizationCodeGrantUri && await this.requestMatcher.match(await this.pathResolver.resolve(this.authorizationCodeGrantUri));
|
|
64
|
+
if (!AuthorizationResponseUtil.isAuthorizationResponse() || !authorizationMatch) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const authorizationRequest = await this.authorizationRequestManager.get();
|
|
68
|
+
if (!authorizationRequest) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return !await this.requestMatcher.match(await this.pathResolver.resolve(this.redirectLoginPath));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
__decorate([
|
|
75
|
+
Autowired(AuthorizationRequestManager),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], AuthorizationCodeGrantMiddleware.prototype, "authorizationRequestManager", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
Autowired(AuthorizationRequestResolver),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], AuthorizationCodeGrantMiddleware.prototype, "authorizationRequestResolver", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
Autowired(ClientRegistrationManager),
|
|
84
|
+
__metadata("design:type", Object)
|
|
85
|
+
], AuthorizationCodeGrantMiddleware.prototype, "clientRegistrationManager", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
Autowired(AuthorizedClientManager),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], AuthorizationCodeGrantMiddleware.prototype, "authorizedClientManager", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
Autowired(RedirectStrategy),
|
|
92
|
+
__metadata("design:type", Object)
|
|
93
|
+
], AuthorizationCodeGrantMiddleware.prototype, "redirectStrategy", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
Autowired(RequestMatcher),
|
|
96
|
+
__metadata("design:type", Object)
|
|
97
|
+
], AuthorizationCodeGrantMiddleware.prototype, "requestMatcher", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
Autowired(PathResolver),
|
|
100
|
+
__metadata("design:type", Object)
|
|
101
|
+
], AuthorizationCodeGrantMiddleware.prototype, "pathResolver", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
Autowired(RequestCache),
|
|
104
|
+
__metadata("design:type", Object)
|
|
105
|
+
], AuthorizationCodeGrantMiddleware.prototype, "requestCache", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
Autowired(AuthorizationCodeTokenResponseClient),
|
|
108
|
+
__metadata("design:type", AuthorizationCodeTokenResponseClient)
|
|
109
|
+
], AuthorizationCodeGrantMiddleware.prototype, "authorizationCodeTokenResponseClient", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
Value(ENDPOINT),
|
|
112
|
+
__metadata("design:type", String)
|
|
113
|
+
], AuthorizationCodeGrantMiddleware.prototype, "endpoint", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
Value(REDIRECT_LOGIN_PATH),
|
|
116
|
+
__metadata("design:type", String)
|
|
117
|
+
], AuthorizationCodeGrantMiddleware.prototype, "redirectLoginPath", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
Value(AUTHORIZATION_CODE_GRANT_URI),
|
|
120
|
+
__metadata("design:type", String)
|
|
121
|
+
], AuthorizationCodeGrantMiddleware.prototype, "authorizationCodeGrantUri", void 0);
|
|
122
|
+
AuthorizationCodeGrantMiddleware = __decorate([
|
|
123
|
+
Component(Middleware)
|
|
124
|
+
], AuthorizationCodeGrantMiddleware);
|
|
125
|
+
export { AuthorizationCodeGrantMiddleware };
|
|
126
|
+
//# sourceMappingURL=authorization-code-grant-middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-code-grant-middleware.js","sourceRoot":"","sources":["../../../src/node/authorization/authorization-code-grant-middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,4CAA4C,EAC5G,uBAAuB,EAAoB,kCAAkC,EAAE,MAAM,0BAA0B,CAAC;AACpH,OAAO,EAAwB,oBAAoB,EAAE,wBAAwB,EAAe,MAAM,qBAAqB,CAAC;AACxH,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAsB,MAAM,iBAAiB,CAAC;AAChF,O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;YACxB,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACrG,CAAC;CAIJ,CAAA;AA7FsB;IADlB,SAAS,CAAC,2BAA2B,CAAC;;qFAC2D;AAG/E;IADlB,SAAS,CAAC,4BAA4B,CAAC;;sFACsC;AAG3D;IADlB,SAAS,CAAC,yBAAyB,CAAC;;mFACmC;AAGrD;IADlB,SAAS,CAAC,uBAAuB,CAAC;;iFACmD;AAGnE;IADlB,SAAS,CAAC,gBAAgB,CAAC;;0EAC0B;AAGnC;IADlB,SAAS,CAAC,cAAc,CAAC;;wEACwB;AAG/B;IADlB,SAAS,CAAC,YAAY,CAAC;;sEACsB;AAG3B;IADlB,SAAS,CAAC,YAAY,CAAC;;sEACsB;AAG3B;IADlB,SAAS,CAAC,oCAAoC,CAAC;8BACS,oCAAoC;8FAAC;AAG3E;IADlB,KAAK,CAAC,QAAQ,CAAC;;kEACoB;AAGjB;IADlB,KAAK,CAAC,mBAAmB,CAAC;;2EACkB;AAG1B;IADlB,KAAK,CAAC,4BAA4B,CAAC;;mFACiB;AApC5C,gCAAgC;IAD5C,SAAS,CAAC,UAAU,CAAC;GACT,gCAAgC,CAgG5C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthorizedClient, AuthorizedClientManager, AuthorizationFailureHandler } from './authorization-protocol.js';
|
|
2
|
+
import { Authentication } from '@celljs/security/lib/node';
|
|
3
|
+
import { OAuth2AuthorizationError } from '@celljs/oauth2-core';
|
|
4
|
+
import { ClientAuthorizationError } from '../error/index.js';
|
|
5
|
+
export declare class DefaultAuthorizationFailureHandler implements AuthorizationFailureHandler {
|
|
6
|
+
protected readonly authorizedClientManager: AuthorizedClientManager<AuthorizedClient>;
|
|
7
|
+
onAuthorizationFailure(oauth2AuthorizationError: OAuth2AuthorizationError, principal: Authentication): Promise<void>;
|
|
8
|
+
protected hasRemovalErrorCode(oauth2AuthorizationError: ClientAuthorizationError): number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { AuthorizationSuccessHandler, AuthorizedClientManager } from './authorization-protocol.js';
|
|
11
|
+
import { Component, Autowired } from '@celljs/core';
|
|
12
|
+
import { OAuth2ErrorCodes } from '@celljs/oauth2-core';
|
|
13
|
+
import { ClientAuthorizationError } from '../error/index.js';
|
|
14
|
+
let DefaultAuthorizationFailureHandler = class DefaultAuthorizationFailureHandler {
|
|
15
|
+
async onAuthorizationFailure(oauth2AuthorizationError, principal) {
|
|
16
|
+
if (oauth2AuthorizationError instanceof ClientAuthorizationError && this.hasRemovalErrorCode(oauth2AuthorizationError)) {
|
|
17
|
+
await this.authorizedClientManager.remove(oauth2AuthorizationError.clientRegistrationId, principal.name);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
hasRemovalErrorCode(oauth2AuthorizationError) {
|
|
21
|
+
return [OAuth2ErrorCodes.INVALID_TOKEN, OAuth2ErrorCodes.INVALID_GRANT].findIndex(code => code === oauth2AuthorizationError.oauth2Error.errorCode);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
Autowired(AuthorizedClientManager),
|
|
26
|
+
__metadata("design:type", Object)
|
|
27
|
+
], DefaultAuthorizationFailureHandler.prototype, "authorizedClientManager", void 0);
|
|
28
|
+
DefaultAuthorizationFailureHandler = __decorate([
|
|
29
|
+
Component(AuthorizationSuccessHandler)
|
|
30
|
+
], DefaultAuthorizationFailureHandler);
|
|
31
|
+
export { DefaultAuthorizationFailureHandler };
|
|
32
|
+
//# sourceMappingURL=authorization-failure-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-failure-handler.js","sourceRoot":"","sources":["../../../src/node/authorization/authorization-failure-handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,2BAA2B,EAAoB,uBAAuB,EAA+B,MAAM,0BAA0B,CAAC;AAE/I,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAA4B,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAG7C,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAK3C,KAAK,CAAC,sBAAsB,CAAC,wBAAkD,EAAE,SAAyB;QACtG,IAAI,wBAAwB,YAAY,wBAAwB,IAAI,IAAI,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,EAAE,CAAC;YACrH,MAAM,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,wBAAwB,CAAC,oBAAoB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7G,CAAC;IACL,CAAC;IAES,mBAAmB,CAAC,wBAAkD;QAC5E,OAAO,CAAE,gBAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,aAAa,CAAE,CAAC,SAAS,CAAE,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,wBAAwB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC1J,CAAC;CAEJ,CAAA;AAZsB;IADlB,SAAS,CAAC,uBAAuB,CAAC;;mFACmD;AAH7E,kCAAkC;IAD9C,SAAS,CAAC,2BAA2B,CAAC;GAC1B,kCAAkC,CAe9C"}
|