Skip to content

Commit a685009

Browse files
yasinmirankjellp
authored andcommitted
feat(localega-tsd-proxy): make token type and oidc provider configurable
make the token type and oidc provider name configurable via env. use TSD_AUTH_TOKEN_TYPE and TSD_AUTH_OIDC_PROVIDER_NAME. both values defaults to "elixir"
1 parent 3ba9161 commit a685009

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

services/localega-tsd-proxy/src/main/java/no/elixir/fega/ltp/controllers/rest/ProxyController.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
@RestController
2020
public class ProxyController {
2121

22-
private static final String TOKEN_TYPE = "elixir";
23-
22+
@Value("${tsd-auth.token-type}")
23+
private String tokenType;
24+
@Value("${tsd-auth.oidc-provider-name}")
25+
private String oidcType;
2426
@Value("${tsd.app-id}")
2527
private String tsdAppId;
26-
2728
@Value("${tsd.app-out-id}")
2829
private String tsdAppOutId;
2930

@@ -55,7 +56,7 @@ public ResponseEntity<?> stream(
5556
throws IOException {
5657

5758
String elixirAAIIdToken = getElixirAAIToken(bearerAuthorization);
58-
Token token = tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, elixirAAIIdToken);
59+
Token token = tsdFileAPIClient.getToken(tokenType, oidcType, elixirAAIIdToken);
5960

6061
byte[] chunkBytes = inputStream.readAllBytes();
6162

@@ -102,7 +103,7 @@ public void stream(
102103
@PathVariable("fileName") String fileName)
103104
throws IOException {
104105
Token token =
105-
tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, getElixirAAIToken(bearerAuthorization));
106+
tsdFileAPIClient.getToken(tokenType, oidcType, getElixirAAIToken(bearerAuthorization));
106107
response.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM.toString());
107108
response.addHeader(
108109
HttpHeaders.CONTENT_DISPOSITION,
@@ -124,7 +125,7 @@ public ResponseEntity<?> getFiles(
124125
@RequestParam(value = "inbox", defaultValue = "true") boolean inbox)
125126
throws IOException {
126127
Token token =
127-
tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, getElixirAAIToken(bearerAuthorization));
128+
tsdFileAPIClient.getToken(tokenType, oidcType, getElixirAAIToken(bearerAuthorization));
128129
return ResponseEntity.ok(
129130
tsdFileAPIClient.listFiles(token.getToken(), inbox ? tsdAppId : tsdAppOutId));
130131
}
@@ -142,7 +143,7 @@ public ResponseEntity<?> deleteFile(
142143
@RequestParam(value = "fileName") String fileName)
143144
throws IOException {
144145
Token token =
145-
tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, getElixirAAIToken(bearerAuthorization));
146+
tsdFileAPIClient.getToken(tokenType, oidcType, getElixirAAIToken(bearerAuthorization));
146147
return ResponseEntity.ok(tsdFileAPIClient.deleteFile(token.getToken(), tsdAppId, fileName));
147148
}
148149

@@ -159,7 +160,7 @@ public ResponseEntity<?> getResumables(
159160
@RequestParam(value = "uploadId", required = false) String uploadId)
160161
throws IOException {
161162
Token token =
162-
tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, getElixirAAIToken(bearerAuthorization));
163+
tsdFileAPIClient.getToken(tokenType, oidcType, getElixirAAIToken(bearerAuthorization));
163164
if (!StringUtils.hasLength(uploadId)) {
164165
return ResponseEntity.ok(tsdFileAPIClient.listResumableUploads(token.getToken(), tsdAppId));
165166
} else {
@@ -181,7 +182,7 @@ public ResponseEntity<?> deleteResumable(
181182
@RequestParam(value = "uploadId") String uploadId)
182183
throws IOException {
183184
Token token =
184-
tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, getElixirAAIToken(bearerAuthorization));
185+
tsdFileAPIClient.getToken(tokenType, oidcType, getElixirAAIToken(bearerAuthorization));
185186
return ResponseEntity.ok(
186187
tsdFileAPIClient.deleteResumableUpload(token.getToken(), tsdAppId, uploadId));
187188
}

services/localega-tsd-proxy/src/main/resources/application.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ token:
4949
aai:
5050
service-base-url: ${AAI_SERVICE_BASE_URL:'https://login.elixir-czech.org'}
5151

52+
tsd-auth:
53+
token-type: ${TSD_AUTH_TOKEN_TYPE:elixir}
54+
oidc-provider-name: ${TSD_AUTH_OIDC_PROVIDER_NAME:elixir} # lifesc
55+
5256
ga4gh:
5357
passport:
5458
# First, the public key is checked. If present, it's used for validating the token and openid-configuration-url is not used.

0 commit comments

Comments
 (0)