Automatically apply configuration accesstoken#540
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for Configuration.accessToken by automatically injecting an Authorization: Bearer <token> header in the generated runtime, and adds tests/docs to validate and explain the behavior.
Changes:
- Add bearer-token auto-injection in
BaseAPI.createFetchParamswhenConfiguration.accessTokenis provided and noAuthorizationheader is already set. - Add unit + integration tests to verify header injection for string/function tokens and non-overwrite behavior.
- Consolidate AAS Repository/Registry generated clients to use the shared
src/generated/runtime.ts(removing per-service runtime copies).
Reviewed changes
Copilot reviewed 3 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/generated/runtime.ts | Inject Authorization header from Configuration.accessToken in the shared runtime. |
| src/unit-tests/generated/runtimeAccessToken.test.ts | New unit tests covering accessToken injection and non-overwrite cases. |
| src/integration-tests/aasRepo.integration.test.ts | Integration coverage ensuring bearer token is attached for AAS repository calls. |
| src/integration-tests/submodelRepo.integration.test.ts | Integration coverage ensuring bearer token is attached for Submodel repository calls. |
| src/generated/AasRepositoryService/runtime.ts | Removed service-local runtime in favor of shared runtime. |
| src/generated/AasRepositoryService/index.ts | Re-export shared runtime instead of service-local runtime. |
| src/generated/AasRepositoryService/apis/SerializationAPIApi.ts | Point runtime import to shared runtime. |
| src/generated/AasRepositoryService/apis/DescriptionAPIApi.ts | Point runtime import to shared runtime. |
| src/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.ts | Point runtime import to shared runtime. |
| src/generated/AasRegistryService/runtime.ts | Removed service-local runtime in favor of shared runtime. |
| src/generated/AasRegistryService/index.ts | Re-export shared runtime instead of service-local runtime. |
| src/generated/AasRegistryService/apis/DescriptionAPIApi.ts | Point runtime import to shared runtime. |
| src/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.ts | Point runtime import to shared runtime. |
| README.md | Document Configuration.accessToken as automatic bearer-token injection (middleware only for advanced auth). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances authentication support by clarifying usage of the
accessTokenoption in theConfigurationobject, and by adding integration tests to ensure that theAuthorizationheader is correctly attached when using this option. The changes improve both documentation and test coverage for authentication behavior.Documentation improvements:
README.mdto document the use of theaccessTokenproperty in theConfigurationobject, clarifying that it enables automatic Bearer token injection and that middleware is only needed for more advanced authentication logic. [1] [2]Authentication integration tests:
aasRepo.integration.test.tsto verify that theAuthorizationheader is set whenaccessTokenis provided in the configuration and that the token is correctly sent with requests.submodelRepo.integration.test.tsto confirm the same behavior for the submodel repository endpoints.Closes #538