ch4mpy / spring-addons

Ease spring OAuth2 resource-servers configuration and testing
Apache License 2.0
552 stars 89 forks source link

Add `@ClasspathClaims` to load a JSON resource from the classpath #128

Closed ch4mpy closed 1 year ago

ch4mpy commented 1 year ago

Is your feature request related to a problem? Please describe. Defining complex claims structure with many annotations can be cumbersome.

@OpenId(
    authorities = { "NICE", "AUTHOR" },
    claims = @OpenIdClaims(
        usernameClaim = "$['https://c4-soft.com/user']['name']", 
        otherClaims = @Claims(
            nestedClaims = @NestedClaims(
                name = "https://c4-soft.com/user",
                stringClaims = { @StringClaim(name = "name", value = "Ch4mp") }))))

Describe the solution you'd like I'd prefer to define claim-sets in JSON files (in the test resources) and load it with a single annotation

@OpenId(
    authorities = { "NICE", "AUTHOR" },
    claims = @OpenIdClaims(
        usernameClaim = "$['https://c4-soft.com/user']['name']", 
        classpathResource = @ClasspathClaims("ch4mp-claims.json")))