Skip to content

Commit

Permalink
chore: remove hard coded urls (#55)
Browse files Browse the repository at this point in the history
Signed-off-by: Bjorn Molin <[email protected]>
  • Loading branch information
bjornmolin authored Jan 23, 2025
1 parent 4ba2442 commit 0380fb9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/se/digg/eudiw/config/EudiwConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Component
public class EudiwConfig {

public record OpenIdFederationConfiguration(String baseUrl, String trustMarkId, String subject, Integer trustListTtlInSeconds, String walletProviderAnchor) {
public record OpenIdFederationConfiguration(String baseUrl, String trustMarkId, String subject, Integer trustListTtlInSeconds, String walletProviderAnchor, String walletBaseUri, List<String> authorityHints) {
}

public record SwedenConnectConfiguration(String baseUrl, String client, String returnBaseUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public ResponseEntity<String> entityStatement() {
.build()
)
.sourceEndpoint(String.format("%s/%s", eudiwConfig.getIssuerBaseUrl(), ".well-known/openid-federation"))
.authorityHints(List.of("https://local.dev.swedenconnect.se:9040/oidfed/intermediate"))
.authorityHints(eudiwConfig.getOpenidFederation().authorityHints())
.trustMarks(List.of(TrustMarkClaim.builder()
.id(eudiwConfig.getOpenidFederation().trustMarkId())
.trustMark(openIdFederationService.trustMark(eudiwConfig.getOpenidFederation().trustMarkId(), eudiwConfig.getOpenidFederation().subject()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ public String welcomeAsHTML(@PathParam("code") String code, @PathParam("state")
}

@GetMapping(value="/callbackdebug", produces = MediaType.TEXT_HTML_VALUE)
String callback(@PathParam("code") String code, @PathParam("state") String state) throws URISyntaxException {
String callback(@PathParam("code") String code, @PathParam("state") String state) {
logger.info("Callback called with code: " + code + " and state: " + state);
// The obtained authorisation code
AuthorizationCode authorizationCode = new AuthorizationCode(code);

// Make the token request, with PKCE
TokenRequest tokenRequest = new TokenRequest(
URI.create("https://local.dev.swedenconnect.se:9090/oauth2/token"),
URI.create(String.format("%s/oauth2/token", eudiwConfig.getIssuerBaseUrl())),
new ClientID(eudiwConfig.getClientId()),
new AuthorizationCodeGrant(authorizationCode, callbackUri, pkceVerifier));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class OpenIdFederationServiceImpl implements OpenIdFederationService {

private final List<TokenCredential> trustedCredentials;

private final String walletUriTemplate;

public OpenIdFederationServiceImpl(@Autowired EudiwConfig eudiwConfig, @Autowired RestTemplate restTemplate, @Autowired List<TokenCredential> tokenCredentials) {
this.eudiwConfig = eudiwConfig;
this.restTemplate = restTemplate;
Expand All @@ -58,15 +60,17 @@ public OpenIdFederationServiceImpl(@Autowired EudiwConfig eudiwConfig, @Autowire
oidFederation = new DefaultApi(client);

trustedCredentials = tokenCredentials;

walletUriTemplate = String.format("%s%%s", eudiwConfig.getOpenidFederation().walletBaseUri());
}

@Override
public WalletOAuthClientMetadata resolveWallet(String walletId) {
WalletOAuthClientMetadata clientMetadata = null;
String oidFedJwt = oidFederation.nameResolveGet(
"wallet-provider",
String.format("https://local.dev.swedenconnect.se/wallets/%s", walletId),
"https://local.dev.swedenconnect.se:9040/oidfed/wallet-provider",
String.format(walletUriTemplate, walletId),
eudiwConfig.getOpenidFederation().walletProviderAnchor(),
null);
try {
SignedJWT signedJwt = parseJwt(oidFedJwt);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ eudiw:
baseUrl: https://local.dev.swedenconnect.se:9040/oidfed
trustMarkId: https://local.dev.swedenconnect.se/trust-mark-id/pid-issuer
walletProviderAnchor: https://local.dev.swedenconnect.se:9040/oidfed/wallet-provider
walletBaseUri: https://local.dev.swedenconnect.se/wallets/
subject: https://local.dev.swedenconnect.se:9090
trustListTtlInSeconds: 60
authorityHints:
- "https://local.dev.swedenconnect.se:9040/oidfed/intermediate"

valkey:
host: local.dev.swedenconnect.se
Expand Down

0 comments on commit 0380fb9

Please sign in to comment.