A bunch of java-spiffe use examples
To run the examples, a SPIRE Server and Agent need to be running.
Download the latest SPIRE from releases github page and extract the tar file.
Copy the content of spire/conf in the SPIRE conf folder.
In a terminal in the SPIRE root folder run:
./spire-server run
./spire-server entry create -parentID spiffe://example.org/host -spiffeID spiffe://example.org/myservice -ttl 300 -selector unix:uid:1000
Change the UID to the UID of the user you will use to run the examples.
For the sake of simplicity the example uses the same identity (myservice
) for both the frontend and backend apps.
Create a join token:
TOKEN=$(./spire-server token generate -spiffeID spiffe://example.org/host | awk -F'Token: ' '{print $2}')
Start the agent using the join token to connect to the server:
./spire-agent run -joinToken $TOKEN
export SPIFFE_ENDPOINT_SOCKET=unix:/tmp/agent.sock
This environment variable is used by the java-spiffe library as a default socket endpoint address to connect to the SPIRE Agent.