-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #736 from catenax-ng/fix/auth-config-properties
fix(BPDM): auth configuration in code not matching properties
- Loading branch information
Showing
62 changed files
with
781 additions
and
1,123 deletions.
There are no files selected for viewing
55 changes: 0 additions & 55 deletions
55
...src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt
This file was deleted.
Oops, something went wrong.
136 changes: 0 additions & 136 deletions
136
bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/ClientsConfig.kt
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/GateClientConfig.kt
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,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
******************************************************************************/ | ||
|
||
package com.catenax.bpdm.bridge.dummy.config | ||
|
||
import org.eclipse.tractusx.bpdm.common.util.BpdmWebClientProvider | ||
import org.eclipse.tractusx.bpdm.common.util.ClientConfigurationProperties | ||
import org.eclipse.tractusx.bpdm.common.util.ConditionalOnBoundProperty | ||
import org.eclipse.tractusx.bpdm.gate.api.client.GateClient | ||
import org.eclipse.tractusx.bpdm.gate.api.client.GateClientImpl | ||
import org.springframework.boot.context.properties.ConfigurationProperties | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService | ||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository | ||
|
||
@ConfigurationProperties(prefix = GateConfigProperties.PREFIX) | ||
data class GateConfigProperties( | ||
override val baseUrl: String = "http://localhost:8081", | ||
override val securityEnabled: Boolean = false, | ||
override val oauth2ClientRegistration: String = "gate-client" | ||
) : ClientConfigurationProperties { | ||
companion object { | ||
const val PREFIX = "${ClientConfigurationProperties.PREFIX}.gate" | ||
} | ||
} | ||
|
||
@Configuration | ||
class GateClientConfiguration( | ||
clientProperties: GateConfigProperties, | ||
) : BpdmWebClientProvider( | ||
clientProperties | ||
) { | ||
@Bean | ||
@ConditionalOnBoundProperty(GateConfigProperties.PREFIX, GateConfigProperties::class, true) | ||
fun authorizedGateClient( | ||
clientRegistrationRepository: ClientRegistrationRepository, | ||
oAuth2AuthorizedClientService: OAuth2AuthorizedClientService | ||
): GateClient = | ||
GateClientImpl { provideAuthorizedClient(clientRegistrationRepository, oAuth2AuthorizedClientService) } | ||
|
||
@Bean | ||
@ConditionalOnBoundProperty(GateConfigProperties.PREFIX, GateConfigProperties::class, false) | ||
fun unauthorizedGateClient(): GateClient = | ||
GateClientImpl { provideUnauthorizedClient() } | ||
} |
30 changes: 0 additions & 30 deletions
30
...bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/GateConfigProperties.kt
This file was deleted.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/PoolClientConfig.kt
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,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
******************************************************************************/ | ||
|
||
package com.catenax.bpdm.bridge.dummy.config | ||
|
||
import org.eclipse.tractusx.bpdm.common.util.BpdmWebClientProvider | ||
import org.eclipse.tractusx.bpdm.common.util.ClientConfigurationProperties | ||
import org.eclipse.tractusx.bpdm.common.util.ConditionalOnBoundProperty | ||
import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient | ||
import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl | ||
import org.springframework.boot.context.properties.ConfigurationProperties | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService | ||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository | ||
|
||
|
||
@ConfigurationProperties(prefix = PoolConfigProperties.PREFIX) | ||
data class PoolConfigProperties( | ||
override val baseUrl: String = "http://localhost:8080", | ||
override val securityEnabled: Boolean = false, | ||
override val oauth2ClientRegistration: String = "pool-client" | ||
) : ClientConfigurationProperties { | ||
companion object { | ||
const val PREFIX = "${ClientConfigurationProperties.PREFIX}.pool" | ||
} | ||
} | ||
|
||
@Configuration | ||
class PoolClientConfiguration( | ||
poolConfigProperties: PoolConfigProperties, | ||
) : BpdmWebClientProvider( | ||
poolConfigProperties | ||
) { | ||
@Bean | ||
@ConditionalOnBoundProperty(PoolConfigProperties.PREFIX, PoolConfigProperties::class, true) | ||
fun authorizedPoolClient( | ||
clientRegistrationRepository: ClientRegistrationRepository, | ||
oAuth2AuthorizedClientService: OAuth2AuthorizedClientService | ||
): PoolApiClient = PoolClientImpl { provideAuthorizedClient(clientRegistrationRepository, oAuth2AuthorizedClientService) } | ||
|
||
@Bean | ||
@ConditionalOnBoundProperty(PoolConfigProperties.PREFIX, PoolConfigProperties::class, false) | ||
fun unauthorizedPoolClient(): PoolApiClient = | ||
PoolClientImpl { provideUnauthorizedClient() } | ||
} |
Oops, something went wrong.