@nocobase/plugin-idp-oauth 2.1.0-alpha.10
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/LICENSE.txt +107 -0
- package/README.md +14 -0
- package/build.config.ts +46 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/ErrorPage.d.ts +11 -0
- package/dist/client/InteractionPage.d.ts +11 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/client/models/index.d.ts +11 -0
- package/dist/client/plugin.d.ts +13 -0
- package/dist/externalVersion.js +18 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/eta/LICENSE +7 -0
- package/dist/node_modules/eta/README.md +185 -0
- package/dist/node_modules/eta/dist/core.d.ts +179 -0
- package/dist/node_modules/eta/dist/core.d.ts.map +1 -0
- package/dist/node_modules/eta/dist/core.js +42 -0
- package/dist/node_modules/eta/dist/core.js.map +1 -0
- package/dist/node_modules/eta/dist/index.cjs +542 -0
- package/dist/node_modules/eta/dist/index.cjs.map +1 -0
- package/dist/node_modules/eta/dist/index.d.cts +187 -0
- package/dist/node_modules/eta/dist/index.d.cts.map +1 -0
- package/dist/node_modules/eta/dist/index.d.mts +187 -0
- package/dist/node_modules/eta/dist/index.d.mts.map +1 -0
- package/dist/node_modules/eta/dist/index.mjs +512 -0
- package/dist/node_modules/eta/dist/index.mjs.map +1 -0
- package/dist/node_modules/eta/package.json +75 -0
- package/dist/node_modules/jose/LICENSE.md +21 -0
- package/dist/node_modules/jose/README.md +153 -0
- package/dist/node_modules/jose/dist/types/index.d.ts +55 -0
- package/dist/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
- package/dist/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
- package/dist/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
- package/dist/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
- package/dist/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +38 -0
- package/dist/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
- package/dist/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
- package/dist/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
- package/dist/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
- package/dist/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
- package/dist/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
- package/dist/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
- package/dist/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
- package/dist/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
- package/dist/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
- package/dist/node_modules/jose/dist/types/jws/general/verify.d.ts +41 -0
- package/dist/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
- package/dist/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
- package/dist/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
- package/dist/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
- package/dist/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
- package/dist/node_modules/jose/dist/types/key/export.d.ts +33 -0
- package/dist/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
- package/dist/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
- package/dist/node_modules/jose/dist/types/key/import.d.ts +83 -0
- package/dist/node_modules/jose/dist/types/types.d.ts +852 -0
- package/dist/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
- package/dist/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
- package/dist/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
- package/dist/node_modules/jose/dist/types/util/errors.d.ts +213 -0
- package/dist/node_modules/jose/dist/webapi/index.js +32 -0
- package/dist/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
- package/dist/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
- package/dist/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +155 -0
- package/dist/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +165 -0
- package/dist/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
- package/dist/node_modules/jose/dist/webapi/jwe/general/encrypt.js +182 -0
- package/dist/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
- package/dist/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
- package/dist/node_modules/jose/dist/webapi/jwks/local.js +119 -0
- package/dist/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
- package/dist/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
- package/dist/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
- package/dist/node_modules/jose/dist/webapi/jws/flattened/sign.js +89 -0
- package/dist/node_modules/jose/dist/webapi/jws/flattened/verify.js +110 -0
- package/dist/node_modules/jose/dist/webapi/jws/general/sign.js +70 -0
- package/dist/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
- package/dist/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
- package/dist/node_modules/jose/dist/webapi/jwt/encrypt.js +101 -0
- package/dist/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
- package/dist/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
- package/dist/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
- package/dist/node_modules/jose/dist/webapi/key/export.js +11 -0
- package/dist/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
- package/dist/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
- package/dist/node_modules/jose/dist/webapi/key/import.js +57 -0
- package/dist/node_modules/jose/dist/webapi/lib/aesgcmkw.js +15 -0
- package/dist/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
- package/dist/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
- package/dist/node_modules/jose/dist/webapi/lib/base64.js +22 -0
- package/dist/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
- package/dist/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
- package/dist/node_modules/jose/dist/webapi/lib/content_encryption.js +217 -0
- package/dist/node_modules/jose/dist/webapi/lib/crypto_key.js +136 -0
- package/dist/node_modules/jose/dist/webapi/lib/deflate.js +44 -0
- package/dist/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
- package/dist/node_modules/jose/dist/webapi/lib/helpers.js +19 -0
- package/dist/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
- package/dist/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
- package/dist/node_modules/jose/dist/webapi/lib/jwk_to_key.js +107 -0
- package/dist/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
- package/dist/node_modules/jose/dist/webapi/lib/key_management.js +186 -0
- package/dist/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
- package/dist/node_modules/jose/dist/webapi/lib/normalize_key.js +166 -0
- package/dist/node_modules/jose/dist/webapi/lib/pbes2kw.js +39 -0
- package/dist/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
- package/dist/node_modules/jose/dist/webapi/lib/signing.js +68 -0
- package/dist/node_modules/jose/dist/webapi/lib/type_checks.js +40 -0
- package/dist/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
- package/dist/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
- package/dist/node_modules/jose/dist/webapi/util/base64url.js +30 -0
- package/dist/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
- package/dist/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
- package/dist/node_modules/jose/dist/webapi/util/errors.js +99 -0
- package/dist/node_modules/jose/package.json +200 -0
- package/dist/node_modules/light-my-request/.gitattributes +2 -0
- package/dist/node_modules/light-my-request/.github/dependabot.yml +13 -0
- package/dist/node_modules/light-my-request/.github/stale.yml +21 -0
- package/dist/node_modules/light-my-request/.github/workflows/benchmark.yml +30 -0
- package/dist/node_modules/light-my-request/.github/workflows/ci.yml +23 -0
- package/dist/node_modules/light-my-request/LICENSE +32 -0
- package/dist/node_modules/light-my-request/benchmark/benchmark.js +164 -0
- package/dist/node_modules/light-my-request/build/build-validation.js +100 -0
- package/dist/node_modules/light-my-request/eslint.config.js +9 -0
- package/dist/node_modules/light-my-request/index.js +2 -0
- package/dist/node_modules/light-my-request/lib/config-validator.js +919 -0
- package/dist/node_modules/light-my-request/lib/form-data.js +79 -0
- package/dist/node_modules/light-my-request/lib/parse-url.js +47 -0
- package/dist/node_modules/light-my-request/lib/request.js +290 -0
- package/dist/node_modules/light-my-request/lib/response.js +240 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.gitattributes +2 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.github/dependabot.yml +13 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.github/workflows/ci.yml +24 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.taprc +2 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/benchmarks/warn.js +25 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/eslint.config.js +6 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/examples/example.js +11 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/index.js +124 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/package.json +73 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-interpolated-string.test.js +29 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-once-only.test.js +28 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-reset.test.js +36 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-set.test.js +30 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-unlimited.test.js +37 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/index.test.js +99 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/issue-88.test.js +33 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/jest.test.js +22 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/no-warnings.test.js +80 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/types/index.d.ts +37 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/types/index.test-d.ts +36 -0
- package/dist/node_modules/light-my-request/package.json +1 -0
- package/dist/node_modules/light-my-request/test/async-await.test.js +55 -0
- package/dist/node_modules/light-my-request/test/index.test.js +2316 -0
- package/dist/node_modules/light-my-request/test/request.test.js +16 -0
- package/dist/node_modules/light-my-request/test/response.test.js +19 -0
- package/dist/node_modules/light-my-request/test/stream.test.js +359 -0
- package/dist/node_modules/light-my-request/types/index.d.ts +128 -0
- package/dist/node_modules/light-my-request/types/index.test-d.ts +149 -0
- package/dist/node_modules/oidc-provider/LICENSE.md +21 -0
- package/dist/node_modules/oidc-provider/README.md +174 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/assign_claims.js +28 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/assign_defaults.js +17 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/authenticated_client_id.js +6 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/backchannel_request_remap_errors.js +17 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/backchannel_request_response.js +41 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_ciba_context.js +12 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_claims.js +68 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_client.js +21 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_client_grant_type.js +21 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_dpop_jkt.js +35 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_extra_params.js +18 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_id_token_hint.js +23 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_max_age.js +25 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_openid_scope.js +47 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_pkce.js +41 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_prompt.js +25 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_redirect_uri.js +41 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_requested_expiry.js +16 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_response_mode.js +54 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_response_type.js +26 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_scope.js +53 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/ciba_load_account.js +58 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/ciba_required.js +13 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_authorization_response.js +31 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow.js +31 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow_errors.js +37 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow_response.js +55 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/index.js +200 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/interaction_emit.js +9 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/interactions.js +149 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/load_account.js +15 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/load_grant.js +29 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/load_pushed_authorization_request.js +36 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/oauth_required.js +11 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/oidc_required.js +27 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/one_redirect_uri_clients.js +20 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/process_request_object.js +214 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/pushed_authorization_request_remap_errors.js +17 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/pushed_authorization_request_response.js +65 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_registration.js +12 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_request_and_uri.js +12 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_unsupported.js +33 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/respond.js +46 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/resume.js +111 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/strip_outside_jar_params.js +19 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/unsupported_rar.js +9 -0
- package/dist/node_modules/oidc-provider/lib/actions/challenge.js +22 -0
- package/dist/node_modules/oidc-provider/lib/actions/code_verification.js +122 -0
- package/dist/node_modules/oidc-provider/lib/actions/discovery.js +151 -0
- package/dist/node_modules/oidc-provider/lib/actions/end_session.js +222 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/authorization_code.js +144 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/ciba.js +127 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/client_credentials.js +79 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/device_code.js +125 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/index.js +7 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/refresh_token.js +229 -0
- package/dist/node_modules/oidc-provider/lib/actions/index.js +25 -0
- package/dist/node_modules/oidc-provider/lib/actions/interaction.js +150 -0
- package/dist/node_modules/oidc-provider/lib/actions/introspection.js +164 -0
- package/dist/node_modules/oidc-provider/lib/actions/jwks.js +7 -0
- package/dist/node_modules/oidc-provider/lib/actions/registration.js +274 -0
- package/dist/node_modules/oidc-provider/lib/actions/revocation.js +81 -0
- package/dist/node_modules/oidc-provider/lib/actions/token.js +74 -0
- package/dist/node_modules/oidc-provider/lib/actions/userinfo.js +183 -0
- package/dist/node_modules/oidc-provider/lib/adapters/memory_adapter.js +95 -0
- package/dist/node_modules/oidc-provider/lib/consts/client_attributes.js +211 -0
- package/dist/node_modules/oidc-provider/lib/consts/dev_keystore.js +18 -0
- package/dist/node_modules/oidc-provider/lib/consts/index.js +13 -0
- package/dist/node_modules/oidc-provider/lib/consts/jwa.js +47 -0
- package/dist/node_modules/oidc-provider/lib/consts/non_rejectable_claims.js +1 -0
- package/dist/node_modules/oidc-provider/lib/consts/param_list.js +23 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/camel_case.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/defaults.js +28 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/difference.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/is_plain_object.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/map_keys.js +9 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/merge.js +25 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/omit_by.js +11 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/pick.js +10 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/pick_by.js +10 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/remove.js +9 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/set.js +18 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/snake_case.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/upper_first.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/account_claims.js +6 -0
- package/dist/node_modules/oidc-provider/lib/helpers/add_client.js +14 -0
- package/dist/node_modules/oidc-provider/lib/helpers/als.js +3 -0
- package/dist/node_modules/oidc-provider/lib/helpers/append_www_authenticate.js +9 -0
- package/dist/node_modules/oidc-provider/lib/helpers/attention.js +23 -0
- package/dist/node_modules/oidc-provider/lib/helpers/base64url.js +11 -0
- package/dist/node_modules/oidc-provider/lib/helpers/certificate_thumbprint.js +15 -0
- package/dist/node_modules/oidc-provider/lib/helpers/challenge.js +111 -0
- package/dist/node_modules/oidc-provider/lib/helpers/check_attest_binding.js +10 -0
- package/dist/node_modules/oidc-provider/lib/helpers/claims.js +79 -0
- package/dist/node_modules/oidc-provider/lib/helpers/client_id_metadata_document.js +198 -0
- package/dist/node_modules/oidc-provider/lib/helpers/client_schema.js +700 -0
- package/dist/node_modules/oidc-provider/lib/helpers/combined_scope.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/configuration.js +544 -0
- package/dist/node_modules/oidc-provider/lib/helpers/constant_equals.js +20 -0
- package/dist/node_modules/oidc-provider/lib/helpers/defaults.js +3510 -0
- package/dist/node_modules/oidc-provider/lib/helpers/epoch_time.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/err_out.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/errors.js +161 -0
- package/dist/node_modules/oidc-provider/lib/helpers/features.js +51 -0
- package/dist/node_modules/oidc-provider/lib/helpers/fetch_body_check.js +25 -0
- package/dist/node_modules/oidc-provider/lib/helpers/fetch_request.js +221 -0
- package/dist/node_modules/oidc-provider/lib/helpers/filter_claims.js +16 -0
- package/dist/node_modules/oidc-provider/lib/helpers/formatters.js +24 -0
- package/dist/node_modules/oidc-provider/lib/helpers/grant_common.js +214 -0
- package/dist/node_modules/oidc-provider/lib/helpers/html_safe.js +19 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_adapter.js +24 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_app.js +243 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_clients.js +24 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_keystore.js +310 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/check.js +21 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/index.js +43 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompt.js +95 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompts/consent.js +105 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompts/login.js +162 -0
- package/dist/node_modules/oidc-provider/lib/helpers/jwt.js +211 -0
- package/dist/node_modules/oidc-provider/lib/helpers/keystore.js +301 -0
- package/dist/node_modules/oidc-provider/lib/helpers/nanoid.js +5 -0
- package/dist/node_modules/oidc-provider/lib/helpers/oidc_context.js +284 -0
- package/dist/node_modules/oidc-provider/lib/helpers/params.js +27 -0
- package/dist/node_modules/oidc-provider/lib/helpers/pkce.js +30 -0
- package/dist/node_modules/oidc-provider/lib/helpers/pkce_format.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/process_response_types.js +202 -0
- package/dist/node_modules/oidc-provider/lib/helpers/re_render_errors.js +39 -0
- package/dist/node_modules/oidc-provider/lib/helpers/redirect_uri.js +16 -0
- package/dist/node_modules/oidc-provider/lib/helpers/resolve_resource.js +33 -0
- package/dist/node_modules/oidc-provider/lib/helpers/resolve_response_mode.js +7 -0
- package/dist/node_modules/oidc-provider/lib/helpers/resource_server.js +20 -0
- package/dist/node_modules/oidc-provider/lib/helpers/revoke.js +27 -0
- package/dist/node_modules/oidc-provider/lib/helpers/script_src_sha.js +21 -0
- package/dist/node_modules/oidc-provider/lib/helpers/sector_identifier.js +19 -0
- package/dist/node_modules/oidc-provider/lib/helpers/sector_validate.js +55 -0
- package/dist/node_modules/oidc-provider/lib/helpers/set_rt_bindings.js +21 -0
- package/dist/node_modules/oidc-provider/lib/helpers/token_find.js +51 -0
- package/dist/node_modules/oidc-provider/lib/helpers/type_validators.js +8 -0
- package/dist/node_modules/oidc-provider/lib/helpers/user_code_form.js +19 -0
- package/dist/node_modules/oidc-provider/lib/helpers/user_codes.js +38 -0
- package/dist/node_modules/oidc-provider/lib/helpers/valid_url.js +8 -0
- package/dist/node_modules/oidc-provider/lib/helpers/validate_dpop.js +129 -0
- package/dist/node_modules/oidc-provider/lib/helpers/validate_presence.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/weak_cache.js +11 -0
- package/dist/node_modules/oidc-provider/lib/index.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/access_token.js +31 -0
- package/dist/node_modules/oidc-provider/lib/models/authorization_code.js +27 -0
- package/dist/node_modules/oidc-provider/lib/models/backchannel_authentication_request.js +26 -0
- package/dist/node_modules/oidc-provider/lib/models/base_model.js +141 -0
- package/dist/node_modules/oidc-provider/lib/models/base_token.js +86 -0
- package/dist/node_modules/oidc-provider/lib/models/client.js +593 -0
- package/dist/node_modules/oidc-provider/lib/models/client_credentials.js +19 -0
- package/dist/node_modules/oidc-provider/lib/models/device_code.js +44 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/dynamic.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/index.js +14 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/jwt.js +198 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/opaque.js +58 -0
- package/dist/node_modules/oidc-provider/lib/models/grant.js +243 -0
- package/dist/node_modules/oidc-provider/lib/models/id_token.js +271 -0
- package/dist/node_modules/oidc-provider/lib/models/index.js +37 -0
- package/dist/node_modules/oidc-provider/lib/models/initial_access_token.js +12 -0
- package/dist/node_modules/oidc-provider/lib/models/interaction.js +73 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/apply.js +4 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/consumable.js +17 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_format.js +46 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_grant_id.js +12 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_grant_type.js +8 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_policies.js +38 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/is_attestation_constrained.js +15 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/is_sender_constrained.js +50 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/is_session_bound.js +38 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/set_audience.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/stores_auth.js +16 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/stores_pkce.js +9 -0
- package/dist/node_modules/oidc-provider/lib/models/pushed_authorization_request.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/refresh_token.js +47 -0
- package/dist/node_modules/oidc-provider/lib/models/registration_access_token.js +8 -0
- package/dist/node_modules/oidc-provider/lib/models/replay_detection.js +31 -0
- package/dist/node_modules/oidc-provider/lib/models/session.js +192 -0
- package/dist/node_modules/oidc-provider/lib/provider.js +453 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/form_post.js +36 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/fragment.js +7 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/index.js +15 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/jwt.js +43 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/query.js +7 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/web_message.js +55 -0
- package/dist/node_modules/oidc-provider/lib/shared/assemble_params.js +7 -0
- package/dist/node_modules/oidc-provider/lib/shared/attest_client_auth.js +111 -0
- package/dist/node_modules/oidc-provider/lib/shared/authorization_error_handler.js +104 -0
- package/dist/node_modules/oidc-provider/lib/shared/check_rar.js +75 -0
- package/dist/node_modules/oidc-provider/lib/shared/check_resource.js +77 -0
- package/dist/node_modules/oidc-provider/lib/shared/client_auth.js +263 -0
- package/dist/node_modules/oidc-provider/lib/shared/conditional_body.js +9 -0
- package/dist/node_modules/oidc-provider/lib/shared/cors.js +49 -0
- package/dist/node_modules/oidc-provider/lib/shared/error_handler.js +59 -0
- package/dist/node_modules/oidc-provider/lib/shared/jwt_client_auth.js +79 -0
- package/dist/node_modules/oidc-provider/lib/shared/no_cache.js +4 -0
- package/dist/node_modules/oidc-provider/lib/shared/reject_dupes.js +45 -0
- package/dist/node_modules/oidc-provider/lib/shared/reject_structured_tokens.js +18 -0
- package/dist/node_modules/oidc-provider/lib/shared/selective_body.js +60 -0
- package/dist/node_modules/oidc-provider/lib/shared/session.js +68 -0
- package/dist/node_modules/oidc-provider/lib/shared/set_www_authenticate_header.js +52 -0
- package/dist/node_modules/oidc-provider/lib/views/index.js +22 -0
- package/dist/node_modules/oidc-provider/lib/views/interaction.js +171 -0
- package/dist/node_modules/oidc-provider/lib/views/layout.js +237 -0
- package/dist/node_modules/oidc-provider/lib/views/login.js +43 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/LICENSE +21 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/README.md +1370 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.d.mts +1003 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.d.ts +1003 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.js +1616 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.mjs +1573 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/package.json +122 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/LICENSE +20 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/README.md +481 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/package.json +64 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/browser.js +272 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/common.js +292 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/index.js +10 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/node.js +263 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/HISTORY.md +186 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/LICENSE +23 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/README.md +169 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/index.js +290 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/package.json +54 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/LICENSE-MIT.txt +20 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/README.md +422 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/bin/jsesc +148 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/jsesc.js +337 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/man/jsesc.1 +94 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/package.json +56 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/LICENSE +20 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/README.md +38 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/bin/nanoid.js +55 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/index.browser.js +29 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/index.d.ts +106 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/index.js +47 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/nanoid.js +1 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/non-secure/index.d.ts +48 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/non-secure/index.js +21 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/package.json +46 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/url-alphabet/index.js +2 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/LICENSE +21 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/Readme.md +224 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.d.ts +144 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js +409 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js.map +1 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/package.json +64 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/HISTORY.md +87 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/LICENSE +23 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/README.md +139 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/codes.json +65 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/index.js +146 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/package.json +49 -0
- package/dist/node_modules/oidc-provider/package.json +95 -0
- package/dist/node_modules/quick-lru/index.d.ts +178 -0
- package/dist/node_modules/quick-lru/index.js +329 -0
- package/dist/node_modules/quick-lru/license +9 -0
- package/dist/node_modules/quick-lru/package.json +54 -0
- package/dist/node_modules/quick-lru/readme.md +236 -0
- package/dist/node_modules/statuses/HISTORY.md +65 -0
- package/dist/node_modules/statuses/LICENSE +23 -0
- package/dist/node_modules/statuses/README.md +127 -0
- package/dist/node_modules/statuses/codes.json +66 -0
- package/dist/node_modules/statuses/index.js +113 -0
- package/dist/node_modules/statuses/package.json +48 -0
- package/dist/server/cache-adapter.d.ts +33 -0
- package/dist/server/cache-adapter.js +159 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +48 -0
- package/dist/server/interaction.d.ts +26 -0
- package/dist/server/interaction.js +172 -0
- package/dist/server/paths.d.ts +19 -0
- package/dist/server/paths.js +64 -0
- package/dist/server/plugin.d.ts +16 -0
- package/dist/server/plugin.js +108 -0
- package/dist/server/provider-dispatch.d.ts +32 -0
- package/dist/server/provider-dispatch.js +252 -0
- package/dist/server/service.d.ts +63 -0
- package/dist/server/service.js +540 -0
- package/dist/server/utils.d.ts +12 -0
- package/dist/server/utils.js +58 -0
- package/package.json +24 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { Cache } from '@nocobase/cache';
|
|
10
|
+
import type Application from '@nocobase/server';
|
|
11
|
+
type ResourceServer = import('oidc-provider').ResourceServer;
|
|
12
|
+
type TokenFormat = import('oidc-provider').TokenFormat;
|
|
13
|
+
export type ResourceServerConfig = {
|
|
14
|
+
path?: string;
|
|
15
|
+
identifier?: string;
|
|
16
|
+
audience?: string;
|
|
17
|
+
scope: string;
|
|
18
|
+
accessTokenTTL?: number;
|
|
19
|
+
accessTokenFormat?: TokenFormat;
|
|
20
|
+
jwt?: ResourceServer['jwt'];
|
|
21
|
+
};
|
|
22
|
+
type ProviderContext = {
|
|
23
|
+
appName: string;
|
|
24
|
+
issuer: string;
|
|
25
|
+
issuerPath: string;
|
|
26
|
+
origin: string;
|
|
27
|
+
};
|
|
28
|
+
export declare class IdpOauthService {
|
|
29
|
+
private readonly app;
|
|
30
|
+
private readonly bridgeTokenCache;
|
|
31
|
+
private providers;
|
|
32
|
+
private pendingProviders;
|
|
33
|
+
private resourceServers;
|
|
34
|
+
private resourceJwks;
|
|
35
|
+
constructor(app: Application, bridgeTokenCache: Cache);
|
|
36
|
+
getOrigin(ctx: any): string;
|
|
37
|
+
getIssuerPath(appName?: string): string;
|
|
38
|
+
getIssuer(origin: string, appName?: string): string;
|
|
39
|
+
getProviderContext(ctx: any): ProviderContext;
|
|
40
|
+
registerResourceServer(name: string, config: ResourceServerConfig): void;
|
|
41
|
+
unregisterResourceServer(name: string): void;
|
|
42
|
+
getSupportedScopes(): string[];
|
|
43
|
+
private resolveResourceIdentifier;
|
|
44
|
+
private getResourceServerInfo;
|
|
45
|
+
private getResolvedResourceIdentifiers;
|
|
46
|
+
private getResourcePath;
|
|
47
|
+
private getRequestResourceConfig;
|
|
48
|
+
private getProviderJwks;
|
|
49
|
+
private generateSigningJwks;
|
|
50
|
+
private getDefaultJwksPath;
|
|
51
|
+
private getProviderSigningJwks;
|
|
52
|
+
private issueInternalToken;
|
|
53
|
+
private getBridgeTokenCacheKey;
|
|
54
|
+
private findUserById;
|
|
55
|
+
resolveInteractionSessionUser(accountId?: string | number): Promise<any>;
|
|
56
|
+
resolveInteractionBridgeUser(ctx: any): Promise<any>;
|
|
57
|
+
authenticateResourceRequest(ctx: any): Promise<any>;
|
|
58
|
+
private getPublicErrorLocation;
|
|
59
|
+
private createConfiguration;
|
|
60
|
+
ensureProviderForContext(ctx: any): Promise<import("oidc-provider").default>;
|
|
61
|
+
ensureProvider(providerContext: ProviderContext): Promise<import("oidc-provider").default>;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var service_exports = {};
|
|
38
|
+
__export(service_exports, {
|
|
39
|
+
IdpOauthService: () => IdpOauthService
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(service_exports);
|
|
42
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
43
|
+
var import_light_my_request = __toESM(require("light-my-request"));
|
|
44
|
+
var import_node_crypto = require("node:crypto");
|
|
45
|
+
var import_node_path = __toESM(require("node:path"));
|
|
46
|
+
var import_cache_adapter = require("./cache-adapter");
|
|
47
|
+
var import_utils = require("./utils");
|
|
48
|
+
let oidcModulePromise = null;
|
|
49
|
+
let joseModulePromise = null;
|
|
50
|
+
function getOidcModule() {
|
|
51
|
+
if (!oidcModulePromise) {
|
|
52
|
+
oidcModulePromise = import("oidc-provider");
|
|
53
|
+
}
|
|
54
|
+
return oidcModulePromise;
|
|
55
|
+
}
|
|
56
|
+
function getJoseModule() {
|
|
57
|
+
if (!joseModulePromise) {
|
|
58
|
+
joseModulePromise = import("jose");
|
|
59
|
+
}
|
|
60
|
+
return joseModulePromise;
|
|
61
|
+
}
|
|
62
|
+
const defaultSupportedScopes = ["openid", "offline_access", "profile", "email"];
|
|
63
|
+
const envJwksKeys = ["IDP_OAUTH_JWKS", "OAUTH_JWKS"];
|
|
64
|
+
class IdpOauthService {
|
|
65
|
+
constructor(app, bridgeTokenCache) {
|
|
66
|
+
this.app = app;
|
|
67
|
+
this.bridgeTokenCache = bridgeTokenCache;
|
|
68
|
+
}
|
|
69
|
+
providers = /* @__PURE__ */ new Map();
|
|
70
|
+
pendingProviders = /* @__PURE__ */ new Map();
|
|
71
|
+
resourceServers = /* @__PURE__ */ new Map();
|
|
72
|
+
resourceJwks = /* @__PURE__ */ new Map();
|
|
73
|
+
getOrigin(ctx) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const protocol = ((_a = ctx.headers) == null ? void 0 : _a["x-forwarded-proto"]) || ctx.protocol || "http";
|
|
76
|
+
const host = ((_b = ctx.headers) == null ? void 0 : _b["x-forwarded-host"]) || ctx.host || "";
|
|
77
|
+
return process.env.APP_PUBLIC_ORIGIN || `${protocol}://${host}`;
|
|
78
|
+
}
|
|
79
|
+
getIssuerPath(appName = this.app.name) {
|
|
80
|
+
const apiBasePath = (0, import_utils.normalizeBasePath)(process.env.API_BASE_PATH || "/api");
|
|
81
|
+
if (appName === "main") {
|
|
82
|
+
return apiBasePath;
|
|
83
|
+
}
|
|
84
|
+
return `${apiBasePath}/__app/${appName}`;
|
|
85
|
+
}
|
|
86
|
+
getIssuer(origin, appName = this.app.name) {
|
|
87
|
+
return `${origin}${this.getIssuerPath(appName)}`;
|
|
88
|
+
}
|
|
89
|
+
getProviderContext(ctx) {
|
|
90
|
+
var _a;
|
|
91
|
+
const appName = ((_a = ctx.app) == null ? void 0 : _a.name) || this.app.name;
|
|
92
|
+
const origin = this.getOrigin(ctx);
|
|
93
|
+
const issuerPath = this.getIssuerPath(appName);
|
|
94
|
+
const issuer = this.getIssuer(origin, appName);
|
|
95
|
+
return {
|
|
96
|
+
appName,
|
|
97
|
+
issuer,
|
|
98
|
+
issuerPath,
|
|
99
|
+
origin
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
registerResourceServer(name, config) {
|
|
103
|
+
this.resourceServers.set(name, config);
|
|
104
|
+
}
|
|
105
|
+
unregisterResourceServer(name) {
|
|
106
|
+
this.resourceServers.delete(name);
|
|
107
|
+
}
|
|
108
|
+
getSupportedScopes() {
|
|
109
|
+
const supportedScopes = new Set(defaultSupportedScopes);
|
|
110
|
+
for (const config of this.resourceServers.values()) {
|
|
111
|
+
for (const scope of config.scope.split(/\s+/)) {
|
|
112
|
+
if (scope) {
|
|
113
|
+
supportedScopes.add(scope);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return [...supportedScopes];
|
|
118
|
+
}
|
|
119
|
+
resolveResourceIdentifier(providerContext, config) {
|
|
120
|
+
if (config.identifier) {
|
|
121
|
+
return config.identifier;
|
|
122
|
+
}
|
|
123
|
+
if (!config.path) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
const normalizedPath = config.path.startsWith("/") ? config.path : `/${config.path}`;
|
|
127
|
+
return new URL(`${providerContext.issuerPath}${normalizedPath}`, providerContext.origin).href;
|
|
128
|
+
}
|
|
129
|
+
getResourceServerInfo(providerContext, resourceIndicator) {
|
|
130
|
+
for (const config of this.resourceServers.values()) {
|
|
131
|
+
const identifier = this.resolveResourceIdentifier(providerContext, config);
|
|
132
|
+
if (!identifier || identifier !== resourceIndicator) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
audience: config.audience || identifier,
|
|
137
|
+
scope: config.scope,
|
|
138
|
+
accessTokenTTL: config.accessTokenTTL,
|
|
139
|
+
accessTokenFormat: config.accessTokenFormat,
|
|
140
|
+
jwt: config.jwt
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
145
|
+
getResolvedResourceIdentifiers(providerContext) {
|
|
146
|
+
const identifiers = [];
|
|
147
|
+
for (const config of this.resourceServers.values()) {
|
|
148
|
+
const identifier = this.resolveResourceIdentifier(providerContext, config);
|
|
149
|
+
if (identifier) {
|
|
150
|
+
identifiers.push(identifier);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return identifiers;
|
|
154
|
+
}
|
|
155
|
+
getResourcePath(config) {
|
|
156
|
+
if (!config.path) {
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
const normalizedPath = config.path.startsWith("/") ? config.path : `/${config.path}`;
|
|
160
|
+
return `${(0, import_utils.normalizeBasePath)(process.env.API_BASE_PATH || "/api")}${normalizedPath}`;
|
|
161
|
+
}
|
|
162
|
+
getRequestResourceConfig(ctx) {
|
|
163
|
+
for (const config of this.resourceServers.values()) {
|
|
164
|
+
const requestPath = this.getResourcePath(config);
|
|
165
|
+
if (requestPath && ctx.path === requestPath) {
|
|
166
|
+
return config;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
async getProviderJwks(provider) {
|
|
172
|
+
if (this.resourceJwks.has(provider.issuer)) {
|
|
173
|
+
return this.resourceJwks.get(provider.issuer);
|
|
174
|
+
}
|
|
175
|
+
const { createLocalJWKSet } = await getJoseModule();
|
|
176
|
+
const issuerPath = (0, import_utils.normalizeBasePath)(new URL(provider.issuer).pathname || "/");
|
|
177
|
+
const jwksPath = provider.pathFor("jwks");
|
|
178
|
+
const internalJwksPath = jwksPath === issuerPath ? "/" : jwksPath.startsWith(`${issuerPath}/`) ? jwksPath.slice(issuerPath.length) || "/" : jwksPath;
|
|
179
|
+
const response = await (0, import_light_my_request.default)(provider.callback(), {
|
|
180
|
+
method: "GET",
|
|
181
|
+
url: internalJwksPath,
|
|
182
|
+
headers: {
|
|
183
|
+
host: new URL(provider.issuer).host,
|
|
184
|
+
accept: "application/json"
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const jwks = response.json();
|
|
188
|
+
const localJwks = createLocalJWKSet(jwks);
|
|
189
|
+
this.resourceJwks.set(provider.issuer, localJwks);
|
|
190
|
+
return localJwks;
|
|
191
|
+
}
|
|
192
|
+
async generateSigningJwks() {
|
|
193
|
+
const { exportJWK, generateKeyPair } = await getJoseModule();
|
|
194
|
+
const { privateKey } = await generateKeyPair("RS256", { extractable: true });
|
|
195
|
+
const privateJwk = await exportJWK(privateKey);
|
|
196
|
+
return {
|
|
197
|
+
keys: [
|
|
198
|
+
{
|
|
199
|
+
...privateJwk,
|
|
200
|
+
kid: privateJwk.kid || "idp-oauth-rs256",
|
|
201
|
+
use: "sig",
|
|
202
|
+
alg: "RS256"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
getDefaultJwksPath(appName) {
|
|
208
|
+
return import_node_path.default.resolve(process.cwd(), "storage", "apps", appName, "idp_oauth_jwks.json");
|
|
209
|
+
}
|
|
210
|
+
async getProviderSigningJwks(appName) {
|
|
211
|
+
const parseJwks = (value, source) => {
|
|
212
|
+
try {
|
|
213
|
+
const jwks = JSON.parse(value);
|
|
214
|
+
if (!jwks || !Array.isArray(jwks.keys) || jwks.keys.length === 0) {
|
|
215
|
+
throw new Error("must be a JSON object with a non-empty keys array");
|
|
216
|
+
}
|
|
217
|
+
return jwks;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
throw new Error(`Failed to parse JWKS from ${source}: ${error.message}`);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
for (const key of envJwksKeys) {
|
|
223
|
+
const value = process.env[key];
|
|
224
|
+
if (value) {
|
|
225
|
+
return parseJwks(value, `environment variable ${key}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const jwksPath = this.getDefaultJwksPath(appName);
|
|
229
|
+
if (import_node_fs.default.existsSync(jwksPath)) {
|
|
230
|
+
return parseJwks(import_node_fs.default.readFileSync(jwksPath, "utf8"), `file ${jwksPath}`);
|
|
231
|
+
}
|
|
232
|
+
const generatedJwks = await this.generateSigningJwks();
|
|
233
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(jwksPath), { recursive: true });
|
|
234
|
+
import_node_fs.default.writeFileSync(jwksPath, JSON.stringify(generatedJwks, null, 2), { mode: 384 });
|
|
235
|
+
return generatedJwks;
|
|
236
|
+
}
|
|
237
|
+
async issueInternalToken(userId, maxExpiresInMs) {
|
|
238
|
+
const tokenInfo = await this.app.authManager.tokenController.add({ userId });
|
|
239
|
+
const config = await this.app.authManager.tokenController.getConfig();
|
|
240
|
+
const expiresInMs = typeof maxExpiresInMs === "number" && Number.isFinite(maxExpiresInMs) ? Math.max(1e3, Math.min(config.tokenExpirationTime, maxExpiresInMs)) : config.tokenExpirationTime;
|
|
241
|
+
const expiresIn = Math.max(1, Math.floor(expiresInMs / 1e3));
|
|
242
|
+
return this.app.authManager.jwt.sign(
|
|
243
|
+
{
|
|
244
|
+
userId,
|
|
245
|
+
temp: true,
|
|
246
|
+
signInTime: tokenInfo.signInTime
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
jwtid: tokenInfo.jti,
|
|
250
|
+
expiresIn
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
getBridgeTokenCacheKey(token, tokenId) {
|
|
255
|
+
return tokenId || (0, import_node_crypto.createHash)("sha256").update(token).digest("hex");
|
|
256
|
+
}
|
|
257
|
+
async findUserById(userId) {
|
|
258
|
+
return this.app.db.getRepository("users").findOne({
|
|
259
|
+
filterByTk: String(userId)
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
async resolveInteractionSessionUser(accountId) {
|
|
263
|
+
if (!accountId) {
|
|
264
|
+
return void 0;
|
|
265
|
+
}
|
|
266
|
+
return this.findUserById(accountId);
|
|
267
|
+
}
|
|
268
|
+
async resolveInteractionBridgeUser(ctx) {
|
|
269
|
+
const { bridge_token: token, bridge_authenticator: authenticator } = ctx.request.body || {};
|
|
270
|
+
if (!token || typeof token !== "string") {
|
|
271
|
+
return void 0;
|
|
272
|
+
}
|
|
273
|
+
const authenticatorName = typeof authenticator === "string" && authenticator ? authenticator : "basic";
|
|
274
|
+
try {
|
|
275
|
+
const auth = await ctx.app.authManager.get(authenticatorName, {
|
|
276
|
+
app: ctx.app,
|
|
277
|
+
db: ctx.db,
|
|
278
|
+
cache: ctx.cache,
|
|
279
|
+
logger: ctx.logger,
|
|
280
|
+
log: ctx.log,
|
|
281
|
+
headers: {
|
|
282
|
+
...ctx.headers,
|
|
283
|
+
authorization: `Bearer ${token}`,
|
|
284
|
+
"x-authenticator": authenticatorName
|
|
285
|
+
},
|
|
286
|
+
req: {
|
|
287
|
+
...ctx.req,
|
|
288
|
+
headers: {
|
|
289
|
+
...ctx.req.headers,
|
|
290
|
+
authorization: `Bearer ${token}`,
|
|
291
|
+
"x-authenticator": authenticatorName
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
get: (name) => {
|
|
295
|
+
var _a;
|
|
296
|
+
const lowerName = name.toLowerCase();
|
|
297
|
+
if (lowerName === "authorization") {
|
|
298
|
+
return `Bearer ${token}`;
|
|
299
|
+
}
|
|
300
|
+
if (lowerName === "x-authenticator") {
|
|
301
|
+
return authenticatorName;
|
|
302
|
+
}
|
|
303
|
+
return (_a = ctx.get) == null ? void 0 : _a.call(ctx, name);
|
|
304
|
+
},
|
|
305
|
+
getBearerToken: () => token,
|
|
306
|
+
throw: (...args) => {
|
|
307
|
+
var _a;
|
|
308
|
+
throw new Error(((_a = args == null ? void 0 : args[0]) == null ? void 0 : _a.message) || (args == null ? void 0 : args[0]) || "Authentication failed");
|
|
309
|
+
},
|
|
310
|
+
t: ctx.t,
|
|
311
|
+
i18n: ctx.i18n,
|
|
312
|
+
state: { ...ctx.state }
|
|
313
|
+
});
|
|
314
|
+
const { user } = await auth.checkToken();
|
|
315
|
+
if (user) {
|
|
316
|
+
ctx.auth = auth;
|
|
317
|
+
ctx.auth.user = user;
|
|
318
|
+
ctx.state.currentUser = user;
|
|
319
|
+
return user;
|
|
320
|
+
}
|
|
321
|
+
return void 0;
|
|
322
|
+
} catch (_error) {
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async authenticateResourceRequest(ctx) {
|
|
327
|
+
var _a, _b, _c;
|
|
328
|
+
const resourceConfig = this.getRequestResourceConfig(ctx);
|
|
329
|
+
if (!resourceConfig) {
|
|
330
|
+
return void 0;
|
|
331
|
+
}
|
|
332
|
+
const token = ((_a = ctx.getBearerToken) == null ? void 0 : _a.call(ctx)) || "";
|
|
333
|
+
if (!token) {
|
|
334
|
+
return void 0;
|
|
335
|
+
}
|
|
336
|
+
const { decodeJwt, jwtVerify } = await getJoseModule();
|
|
337
|
+
const providerContext = this.getProviderContext(ctx);
|
|
338
|
+
const audience = this.resolveResourceIdentifier(providerContext, resourceConfig);
|
|
339
|
+
(_c = (_b = ctx.logger) == null ? void 0 : _b.debug) == null ? void 0 : _c.call(_b, "idp-oauth authenticate resource request", {
|
|
340
|
+
path: ctx.path,
|
|
341
|
+
issuer: providerContext.issuer,
|
|
342
|
+
audience,
|
|
343
|
+
hasBearerToken: !!token
|
|
344
|
+
});
|
|
345
|
+
try {
|
|
346
|
+
const decoded = decodeJwt(token);
|
|
347
|
+
if (decoded.iss !== providerContext.issuer) {
|
|
348
|
+
return void 0;
|
|
349
|
+
}
|
|
350
|
+
} catch (_error) {
|
|
351
|
+
return void 0;
|
|
352
|
+
}
|
|
353
|
+
const provider = await this.ensureProvider(providerContext);
|
|
354
|
+
const keySet = await this.getProviderJwks(provider);
|
|
355
|
+
let payload;
|
|
356
|
+
try {
|
|
357
|
+
({ payload } = await jwtVerify(token, keySet, {
|
|
358
|
+
issuer: providerContext.issuer,
|
|
359
|
+
audience
|
|
360
|
+
}));
|
|
361
|
+
} catch (error) {
|
|
362
|
+
return void 0;
|
|
363
|
+
}
|
|
364
|
+
if (typeof payload.sub !== "string" || !payload.sub) {
|
|
365
|
+
ctx.throw(401, "Invalid token subject");
|
|
366
|
+
}
|
|
367
|
+
const user = await this.app.db.getRepository("users").findOne({
|
|
368
|
+
filterByTk: payload.sub
|
|
369
|
+
});
|
|
370
|
+
if (!user) {
|
|
371
|
+
ctx.throw(401, "User not found");
|
|
372
|
+
}
|
|
373
|
+
const oauthExpiresInMs = typeof payload.exp === "number" ? Math.max(0, payload.exp * 1e3 - Date.now()) : void 0;
|
|
374
|
+
const bridgeTokenCacheKey = this.getBridgeTokenCacheKey(
|
|
375
|
+
token,
|
|
376
|
+
typeof payload.jti === "string" ? payload.jti : void 0
|
|
377
|
+
);
|
|
378
|
+
const cachedInternalToken = await this.bridgeTokenCache.get(bridgeTokenCacheKey);
|
|
379
|
+
const internalToken = cachedInternalToken || await this.issueInternalToken(user.id, oauthExpiresInMs);
|
|
380
|
+
if (!cachedInternalToken && typeof oauthExpiresInMs === "number" && oauthExpiresInMs > 0) {
|
|
381
|
+
await this.bridgeTokenCache.set(bridgeTokenCacheKey, internalToken, oauthExpiresInMs);
|
|
382
|
+
}
|
|
383
|
+
const authorizationHeader = `Bearer ${internalToken}`;
|
|
384
|
+
ctx.req.headers.authorization = authorizationHeader;
|
|
385
|
+
ctx.req.headers["x-authenticator"] = "basic";
|
|
386
|
+
ctx.state.currentUser = user;
|
|
387
|
+
ctx.auth = ctx.auth || {};
|
|
388
|
+
ctx.auth.user = user;
|
|
389
|
+
return user;
|
|
390
|
+
}
|
|
391
|
+
getPublicErrorLocation(appName, out) {
|
|
392
|
+
const query = new URLSearchParams();
|
|
393
|
+
for (const [key, value] of Object.entries(out || {})) {
|
|
394
|
+
if (typeof value === "undefined" || value === null) {
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
query.set(key, String(value));
|
|
398
|
+
}
|
|
399
|
+
return `/idp-oauth/error/${appName}${query.size ? `?${query.toString()}` : ""}`;
|
|
400
|
+
}
|
|
401
|
+
async createConfiguration({ appName, issuer, issuerPath, origin }) {
|
|
402
|
+
const app = this.app;
|
|
403
|
+
const cookieKey = this.app.authManager.jwt.getSecret();
|
|
404
|
+
if (!cookieKey) {
|
|
405
|
+
throw new Error("JWT secret is required for plugin-idp-oauth");
|
|
406
|
+
}
|
|
407
|
+
const jwks = await this.getProviderSigningJwks(appName);
|
|
408
|
+
return {
|
|
409
|
+
adapter: (0, import_cache_adapter.createCacheAdapter)(this.app.cache, "idp-oauth"),
|
|
410
|
+
clients: [],
|
|
411
|
+
scopes: this.getSupportedScopes(),
|
|
412
|
+
jwks,
|
|
413
|
+
cookies: {
|
|
414
|
+
keys: [cookieKey]
|
|
415
|
+
},
|
|
416
|
+
claims: {
|
|
417
|
+
openid: ["sub"],
|
|
418
|
+
profile: ["name", "preferred_username"],
|
|
419
|
+
email: ["email", "email_verified"]
|
|
420
|
+
},
|
|
421
|
+
interactions: {
|
|
422
|
+
url(_ctx, interaction) {
|
|
423
|
+
return `/idp-oauth/interaction/${appName}/${interaction.uid}`;
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
routes: {
|
|
427
|
+
authorization: "/idpOAuth/authorize",
|
|
428
|
+
token: "/idpOAuth/token",
|
|
429
|
+
jwks: "/idpOAuth/jwks",
|
|
430
|
+
registration: "/idpOAuth/register",
|
|
431
|
+
revocation: "/idpOAuth/revoke",
|
|
432
|
+
userinfo: "/idpOAuth/me",
|
|
433
|
+
introspection: "/idpOAuth/introspection",
|
|
434
|
+
end_session: "/idpOAuth/end-session"
|
|
435
|
+
},
|
|
436
|
+
features: {
|
|
437
|
+
devInteractions: { enabled: false },
|
|
438
|
+
registration: { enabled: true },
|
|
439
|
+
revocation: { enabled: true },
|
|
440
|
+
resourceIndicators: {
|
|
441
|
+
enabled: true,
|
|
442
|
+
useGrantedResource: async () => true,
|
|
443
|
+
// Temporary compatibility fallback for current Codex MCP OAuth login behavior.
|
|
444
|
+
// Codex may omit the RFC 8707 resource parameter during authorize/token requests,
|
|
445
|
+
// so when there is only one registered protected resource we default to it here.
|
|
446
|
+
// Track upstream fix: https://github.com/openai/codex/issues/13891
|
|
447
|
+
// This can be removed once the client consistently sends resource.
|
|
448
|
+
defaultResource: async (_ctx, _client, oneOf) => {
|
|
449
|
+
if ((oneOf == null ? void 0 : oneOf.length) === 1) {
|
|
450
|
+
return oneOf[0];
|
|
451
|
+
}
|
|
452
|
+
const identifiers = this.getResolvedResourceIdentifiers({ appName, issuer, issuerPath, origin });
|
|
453
|
+
if (identifiers.length === 1) {
|
|
454
|
+
return identifiers[0];
|
|
455
|
+
}
|
|
456
|
+
return void 0;
|
|
457
|
+
},
|
|
458
|
+
getResourceServerInfo: async (_ctx, resourceIndicator) => {
|
|
459
|
+
const resourceServer = this.getResourceServerInfo(
|
|
460
|
+
{ appName, issuer, issuerPath, origin },
|
|
461
|
+
resourceIndicator
|
|
462
|
+
);
|
|
463
|
+
if (resourceServer) {
|
|
464
|
+
return resourceServer;
|
|
465
|
+
}
|
|
466
|
+
const oidc = await getOidcModule();
|
|
467
|
+
throw new oidc.errors.InvalidTarget();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
ttl: {
|
|
472
|
+
AccessToken: () => 10 * 60,
|
|
473
|
+
AuthorizationCode: 60,
|
|
474
|
+
Grant: 14 * 24 * 60 * 60,
|
|
475
|
+
IdToken: 60 * 60,
|
|
476
|
+
RefreshToken: () => 30 * 24 * 60 * 60,
|
|
477
|
+
Session: 14 * 24 * 60 * 60,
|
|
478
|
+
Interaction: 60 * 60
|
|
479
|
+
},
|
|
480
|
+
pkce: {
|
|
481
|
+
required: () => true
|
|
482
|
+
},
|
|
483
|
+
findAccount: async (_ctx, sub) => {
|
|
484
|
+
const repo = app.db.getRepository("users");
|
|
485
|
+
const user = await repo.findOne({
|
|
486
|
+
filterByTk: sub
|
|
487
|
+
});
|
|
488
|
+
if (!user) {
|
|
489
|
+
return void 0;
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
accountId: String(user.id),
|
|
493
|
+
claims: async () => ({
|
|
494
|
+
sub: String(user.id),
|
|
495
|
+
name: user.nickname || user.username || user.email,
|
|
496
|
+
preferred_username: user.username,
|
|
497
|
+
email: user.email,
|
|
498
|
+
email_verified: !!user.email
|
|
499
|
+
})
|
|
500
|
+
};
|
|
501
|
+
},
|
|
502
|
+
extraTokenClaims: async (_ctx, token) => {
|
|
503
|
+
return {
|
|
504
|
+
client_id: token.clientId,
|
|
505
|
+
iss: issuer
|
|
506
|
+
};
|
|
507
|
+
},
|
|
508
|
+
renderError: async (ctx, out) => {
|
|
509
|
+
ctx.status = 302;
|
|
510
|
+
ctx.redirect(this.getPublicErrorLocation(appName, out));
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
async ensureProviderForContext(ctx) {
|
|
515
|
+
return this.ensureProvider(this.getProviderContext(ctx));
|
|
516
|
+
}
|
|
517
|
+
async ensureProvider(providerContext) {
|
|
518
|
+
const { issuer } = providerContext;
|
|
519
|
+
if (this.providers.has(issuer)) {
|
|
520
|
+
return this.providers.get(issuer);
|
|
521
|
+
}
|
|
522
|
+
if (this.pendingProviders.has(issuer)) {
|
|
523
|
+
return this.pendingProviders.get(issuer);
|
|
524
|
+
}
|
|
525
|
+
const pending = getOidcModule().then(async (oidc) => {
|
|
526
|
+
const provider = new oidc.Provider(issuer, await this.createConfiguration(providerContext));
|
|
527
|
+
provider.proxy = true;
|
|
528
|
+
this.providers.set(issuer, provider);
|
|
529
|
+
return provider;
|
|
530
|
+
}).finally(() => {
|
|
531
|
+
this.pendingProviders.delete(issuer);
|
|
532
|
+
});
|
|
533
|
+
this.pendingProviders.set(issuer, pending);
|
|
534
|
+
return pending;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
538
|
+
0 && (module.exports = {
|
|
539
|
+
IdpOauthService
|
|
540
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { IdpOauthService } from './service';
|
|
10
|
+
export declare function normalizeBasePath(path?: string): string;
|
|
11
|
+
export declare function getCurrentUser(ctx: any): any;
|
|
12
|
+
export declare function resolveCurrentUser(ctx: any, service?: IdpOauthService): Promise<any>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var utils_exports = {};
|
|
28
|
+
__export(utils_exports, {
|
|
29
|
+
getCurrentUser: () => getCurrentUser,
|
|
30
|
+
normalizeBasePath: () => normalizeBasePath,
|
|
31
|
+
resolveCurrentUser: () => resolveCurrentUser
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(utils_exports);
|
|
34
|
+
function normalizeBasePath(path = "") {
|
|
35
|
+
const normalized = path.replace(/\/+/g, "/").replace(/\/$/, "");
|
|
36
|
+
return normalized || "/";
|
|
37
|
+
}
|
|
38
|
+
function getCurrentUser(ctx) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
return ((_a = ctx.auth) == null ? void 0 : _a.user) || ((_b = ctx.state) == null ? void 0 : _b.currentUser);
|
|
41
|
+
}
|
|
42
|
+
async function resolveCurrentUser(ctx, service) {
|
|
43
|
+
const currentUser = getCurrentUser(ctx);
|
|
44
|
+
if (currentUser) {
|
|
45
|
+
return currentUser;
|
|
46
|
+
}
|
|
47
|
+
const bridgeUser = service ? await service.resolveInteractionBridgeUser(ctx) : void 0;
|
|
48
|
+
if (bridgeUser) {
|
|
49
|
+
return bridgeUser;
|
|
50
|
+
}
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
getCurrentUser,
|
|
56
|
+
normalizeBasePath,
|
|
57
|
+
resolveCurrentUser
|
|
58
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nocobase/plugin-idp-oauth",
|
|
3
|
+
"version": "2.1.0-alpha.10",
|
|
4
|
+
"main": "dist/server/index.js",
|
|
5
|
+
"displayName": "IdP: OAuth",
|
|
6
|
+
"displayName.zh-CN": "IdP: OAuth",
|
|
7
|
+
"description": "Based on OAuth 2.1 and OpenID Connect, this plugin enables NocoBase to act as an identity provider for other systems.",
|
|
8
|
+
"description.zh-CN": "基于 OAuth 2.1 和 OpenID Connect 协议,支持 NocoBase 作为身份提供方登录其他系统。",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/oidc-provider": "^9.5.0",
|
|
11
|
+
"jose": "^6.2.1",
|
|
12
|
+
"light-my-request": "^6.6.0",
|
|
13
|
+
"oidc-provider": "~9.7.0"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@nocobase/client": "2.x",
|
|
17
|
+
"@nocobase/server": "2.x",
|
|
18
|
+
"@nocobase/test": "2.x"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"Authentication"
|
|
22
|
+
],
|
|
23
|
+
"gitHead": "ce790d46c0a5768ca9618c7d0d77ab8300de75c8"
|
|
24
|
+
}
|