-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a set of conditionals to avoid ClientCredentialAutoConfiguratio…
…n and TokenServiceAutoConfiguration having different conditionals.
- Loading branch information
Showing
6 changed files
with
132 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
39 changes: 39 additions & 0 deletions
39
...nav/libs/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForAzure.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package no.nav.testnav.libs.securitycore.domain.azuread; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; | ||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Conditional that matches if the application is configured for Azure. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Conditional(OnDollyApplicationConfiguredForAzureCondition.class) | ||
public @interface ConditionalOnDollyApplicationConfiguredForAzure { | ||
} | ||
|
||
class OnDollyApplicationConfiguredForAzureCondition extends SpringBootCondition { | ||
|
||
@Override | ||
public ConditionOutcome getMatchOutcome( | ||
ConditionContext context, | ||
AnnotatedTypeMetadata metadata | ||
) { | ||
var issuerUri = context | ||
.getEnvironment() | ||
.getProperty("AAD_ISSUER_URI"); | ||
// Check for AZURE_APP_CLIENT_ID/AZURE_APP_CLIENT_SECRET? | ||
var match = StringUtils.hasText(issuerUri); | ||
var message = match ? "Dolly application configured for Azure." : "Dolly application not configured for Azure. Missing required property 'AAD_ISSUER_URI'"; | ||
return new ConditionOutcome(match, message); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...stnav/libs/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForNav.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package no.nav.testnav.libs.securitycore.domain.azuread; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; | ||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
|
||
/** | ||
* Conditional that matches if the application is configured for Nav. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Conditional(OnDollyApplicationConfiguredForNavCondition.class) | ||
public @interface ConditionalOnDollyApplicationConfiguredForNav { | ||
} | ||
|
||
class OnDollyApplicationConfiguredForNavCondition extends SpringBootCondition { | ||
|
||
@Override | ||
public ConditionOutcome getMatchOutcome( | ||
ConditionContext context, | ||
AnnotatedTypeMetadata metadata | ||
) { | ||
var issuerUri = context | ||
.getEnvironment() | ||
.getProperty("AZURE_NAV_OPENID_CONFIG_TOKEN_ENDPOINT"); | ||
// Check for AZURE_NAV_APP_CLIENT_ID/AZURE_NAV_APP_CLIENT_SECRET? | ||
var match = StringUtils.hasText(issuerUri); | ||
var message = match ? "Dolly application configured for Nav." : "Dolly application not configured for Nav. Missing required property 'AZURE_NAV_OPENID_CONFIG_TOKEN_ENDPOINT'"; | ||
return new ConditionOutcome(match, message); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...s/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForTrygdeetaten.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package no.nav.testnav.libs.securitycore.domain.azuread; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; | ||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
|
||
/** | ||
* Conditional that matches if the application is configured for Trygdeetaten. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Conditional(OnDollyApplicationConfiguredForTrygdeetatenCondition.class) | ||
public @interface ConditionalOnDollyApplicationConfiguredForTrygdeetaten { | ||
} | ||
|
||
class OnDollyApplicationConfiguredForTrygdeetatenCondition extends SpringBootCondition { | ||
|
||
@Override | ||
public ConditionOutcome getMatchOutcome( | ||
ConditionContext context, | ||
AnnotatedTypeMetadata metadata | ||
) { | ||
var issuerUri = context | ||
.getEnvironment() | ||
.getProperty("AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT"); | ||
// Check for AZURE_TRYGDEETATEN_APP_CLIENT_ID/AZURE_TRYGDEETATEN_APP_CLIENT_SECRET? | ||
var match = StringUtils.hasText(issuerUri); | ||
var message = match ? "Dolly application configured for Trygdeetaten." : "Dolly application not configured for Trygdeetaten. Missing required property 'AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT'"; | ||
return new ConditionOutcome(match, message); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
TOKEN_X_ISSUER: | ||
AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT: | ||
TOKEN_X_ISSUER: placeholder | ||
AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT: placeholder | ||
|
||
app: | ||
elastic: | ||
username: | ||
password: | ||
hendelse.lager.api.key: | ||
person.aktor.api.key: | ||
username: placeholder | ||
password: placeholder | ||
hendelse.lager.api.key: placeholder | ||
person.aktor.api.key: placeholder |