Sign inSign up

snebesky/jwt

By snebesky

Updated about 3 years ago

Image
0

197

snebesky/jwt repository overview

JWT Web service

Web service to return JSON Web Token (JWT) for authentication.

Configure web service

A configuration file needs to be passed to the JWT web service on start.

jwt.properties


PRIVATE_KEY=""
ISS=""
AUD=""
SCOPE=""
KID=""
ALGO=""
USERNAME=""
PASSWORD_HASH=""

PRIVATE_KEY - Private key to sign the JWT.

openssl can be used to generate the private key.

>> openssl ecparam -name prime256v1 -genkey -noout -out private-key.pem
>> openssl pkcs8 -in private-key.pem -topk8 -nocrypt -out key.pk8
>> cat key.pk8
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgAKuj+/OE4vm5XB28
/+zMSsUAdudgqHY5g2moR+5wpj2hRANCAAR3aoFEIaT2I91j4ZtpkPWWJDxeKPaE
YqzkGj3GP4YpWQFQG+DxWBEFQuhlPJnvqs1R4Eg4mngs/pHpZ+0XgRwR
-----END PRIVATE KEY-----

ALGO - The specific cryptographic algorithm used with the key (ES256, ES384, ES512, RS256, RS384, etc.).

ISS - Issuer of the JWT.

AUD - Recipient for which the JWT is intended.

SCOPE - Necessary permissions (scope of access).

KID - The unique identifier for the key.

USERNAME - Username for API authentication, can have any value

PASSWORD_HASH - SHA256 password hash of the password used for API authentication. The hash can be obtained using some hasing tool.

>> echo -n "my_secret_password" | shasum -a 256
6586bc035202dff98a67b814aca615e613cbbfae8ffa8f4a475da0faef079c9d

Example jwt.properties file.

jwt.properties


PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgAKuj+/OE4vm5XB28/+zMSsUAdudgqHY5g2moR+5wpj2hRANCAAR3aoFEIaT2I91j4ZtpkPWWJDxeKPaEYqzkGj3GP4YpWQFQG+DxWBEFQuhlPJnvqs1R4Eg4mngs/pHpZ+0XgRwR\n-----END PRIVATE KEY-----"
ISS="https://example.io/oidc/d1_sandbox"
AUD="https://example.io/oidc/d1_sandbox"
SCOPE="user:write"
KID="kid_1"
ALGO="ES256"
USERNAME="my_user"
PASSWORD_HASH="6586bc035202dff98a67b814aca615e613cbbfae8ffa8f4a475da0faef079c9d"

Running the web service

# pull docker image
>> docker pull snebesky/jwt
# run docker image
>> docker run -d -p 3002:80 -v /path/to/jwt.properties:/etc/config/jwt.properties snebesky/jwt

Access and test web service

curl examples of accessing the web service API.

>> curl -u "my_user:my_secret_password" http://127.0.0.1:3002/protected/sandbox/jwt/bpsd1-msdk-204uc00x-4500-4690-8a20-2afc295c44bf

References

JSON Web Token (JWT).

curl.

docker.

Tag summary

Content type

Image

Digest

sha256:aaad42b1f

Size

338.4 MB

Last updated

about 3 years ago

docker pull snebesky/jwt