JBoss CLI: add a nested element within an element without name attribute (adding "key" element inside "jwt")

572 views Asked by At

Generally speaking, I am trying to add a nested element inside another one, where the parent element does not contain a name attribute:

<parentElement name="fooName">
    <foo property1="abc"/>
</parentElement>

should become:

<parentElement name="fooName">
    <foo property1="abc">
        <fooChild property2="bcd"/>
    </foo>
</parent>

The problem with this is that I cannot find a way to properly build the path for the CLI command:

/sybsystem=xxx/parentElement=fooName/foo:add(fooChild={property2="bcd"})

gives me an error Node path format is wrong around 'foo' (index=37).

I assume this is because the foo element doesn't have an attribute name.


More specifically I am looking for a way to add key element inside the jwt element:

         <token-realm name="jwt-realm" principal-claim="sub">
                <jwt issuer="${JWT_ISSUER}" audience="${JWT_AUDIENCE}" public-key="${JWT_PUBLIC_KEY}"/>
         </token-realm>

should become:

           <token-realm name="jwt-realm" principal-claim="sub">
                <jwt issuer="${JWT_ISSUER}" audience="${JWT_AUDIENCE}" public-key="${JWT_PUBLIC_KEY}">
                    <key kid="xxx" public-key="${JWT_PUBLIC_KEY}"/>
                </jwt>
           </token-realm>

The command I am trying to use:

/subsystem=elytron/token-realm=jwt-realm/jwt:add(key={kid="xxx",public-key="${JWT_PUBLIC_KEY}"})

and the error I get: Node path format is wrong around 'jwt' (index=41).

2

There are 2 answers

0
Andremoniy On

Thanks to my outstanding colleague (he hasn't got an account here, shame), the answer has been found.

To update the key's map the following command can be used:

/subsystem=elytron/token-realm=jwt-realm:write-attribute(name=jwt, ... ,key-map={"xxx","${JWT_PUBLIC_KEY}"}}) 

(... here the list of other standard attributes of the jwt element).

0
Milad On

For me this did it (whereas the suggested solution didn't), I am using WildFly 31:

/subsystem=elytron/token-realm=jwt-realm:add(jwt={issuer=["quickstart-jwt-issuer"], audience=["jwt-audience"], key-map={1="-----BEGIN PUBLIC KEY-----MII...AAE=-----END PUBLIC KEY-----"}}, principal-claim="sub")

This created this element in the standalone.xml file:

<token-realm name="jwt-realm" principal-claim="sub">
    <jwt issuer="quickstart-jwt-issuer" audience="jwt-audience">
        <key kid="1" public-key="-----BEGIN PUBLIC KEY-----MII...AAE=-----END PUBLIC KEY-----"/>
    </jwt>
</token-realm>

Hope this helps.