Skip to content

Commit fc3c18b

Browse files
zhou9584Le Zhou
andauthored
[Feature] add HYBRID config of api auth mode to support switch in center (#704)
<!-- Please provide brief information about the PR, what it contains & its purpose, new behaviors after the change. And let us know here if you need any help: https://github.com/microsoft/HydraLab/issues/new --> ## Description <!-- A few words to explain your changes --> ### Linked GitHub issue ID: # ## Pull Request Checklist <!-- Put an x in the boxes that apply. This is simply a reminder of what we are going to look for before merging your code. --> - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Code compiles correctly with all tests are passed. - [x] I've read the [contributing guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code) and followed the recommended practices. - [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or [README](https://github.com/microsoft/HydraLab/blob/main/README.md) have been reviewed and added / updated if needed (for bug fixes / features) ### Does this introduce a breaking change? *If this introduces a breaking change for Hydra Lab users, please describe the impact and migration path.* - [ ] Yes - [x] No ## How you tested it *Please make sure the change is tested, you can test it by adding UTs, do local test and share the screenshots, etc.* Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Technical design - [ ] Build related changes - [ ] Refactoring (no functional changes, no api changes) - [ ] Code style update (formatting, renaming) or Documentation content changes - [ ] Other (please describe): ### Feature UI screenshots or Technical design diagrams *If this is a relatively large or complex change, kick it off by drawing the tech design with PlantUML and explaining why you chose the solution you did and what alternatives you considered, etc...* Co-authored-by: Le Zhou <zhoule@microsoft.com>
1 parent 2be52f0 commit fc3c18b

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

center/src/main/java/com/microsoft/hydralab/center/interceptor/BaseInterceptor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
9494

9595
// invoked by agent client
9696
if (!StringUtils.isEmpty(authorizationToken)) {
97-
if ("SECRET".equals(apiAuthMode) && authTokenService.checkAuthToken(authorizationToken)) {
97+
if ("HYBRID".equals(apiAuthMode) && (authTokenService.checkAuthToken(authorizationToken) ||
98+
authTokenService.setUserAuthByAppClientToken(authorizationToken))) {
99+
return true;
100+
} else if ("SECRET".equals(apiAuthMode) && authTokenService.checkAuthToken(authorizationToken)) {
98101
return true;
99102
} else if ("TOKEN".equals(apiAuthMode) && authTokenService.setUserAuthByAppClientToken(authorizationToken)) {
100103
return true;

center/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ app:
8484
deployment: ${OPENAI_DEPLOYMENT:}
8585
endpoint: ${OPENAI_ENDPOINT:}
8686
agent-auth-mode: ${AGENT_AUTH_MODE:SECRET} # options: TOKEN, SECRET
87-
api-auth-mode: ${API_AUTH_MODE:SECRET} # options: TOKEN, SECRET
87+
api-auth-mode: ${API_AUTH_MODE:SECRET} # options: TOKEN, SECRET, HYBRID
8888
management:
8989
endpoints:
9090
web:

0 commit comments

Comments
 (0)