Skip to content

Commit

Permalink
Merge pull request #741 from catenax-ng/fix/gate/owner-property-nullable
Browse files Browse the repository at this point in the history
fix(Gate): empty owner BPNL leading to forbidden errors
  • Loading branch information
nicoprow authored Feb 7, 2024
2 parents 57d994c + 1f03b37 commit 52a27e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import java.util.stream.Collectors
* }
*
*/
class CustomJwtAuthenticationConverter(private val resourceId: String, private val requiredBpn: String? = null) : Converter<Jwt, AbstractAuthenticationToken> {
class CustomJwtAuthenticationConverter(private val resourceId: String, private val requiredBpn: String = "") : Converter<Jwt, AbstractAuthenticationToken> {
private val defaultGrantedAuthoritiesConverter = JwtGrantedAuthoritiesConverter()

override fun convert(source: Jwt): AbstractAuthenticationToken {
Expand All @@ -63,8 +63,8 @@ class CustomJwtAuthenticationConverter(private val resourceId: String, private v

@Suppress("UNCHECKED_CAST")
companion object {
private fun extractResourceRoles(jwt: Jwt, resourceId: String, requiredBpn: String? = null): Collection<GrantedAuthority> {
if (requiredBpn != null && requiredBpn != jwt.claims["bpn"]) {
private fun extractResourceRoles(jwt: Jwt, resourceId: String, requiredBpn: String = ""): Collection<GrantedAuthority> {
if (requiredBpn.isNotBlank() && requiredBpn != jwt.claims["bpn"]) {
return emptyList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ data class BpnConfigProperties(
val agencyName: String = "Catena-X",
var name: String = "Business Partner Number",
val id: String = "CX_BPN",
val ownerBpnL: String? = null
val ownerBpnL: String = ""
)
3 changes: 2 additions & 1 deletion bpdm-gate/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ bpdm:
agency-name: Catena-X
id: CX_BPN
name: Business Partner Number
owner-bpn-l: '# Insert owner BPNL here'
# Insert owner BPNL here
owner-bpn-l:
api:
upsert-limit: 100

Expand Down

0 comments on commit 52a27e1

Please sign in to comment.