{"id":20348537,"url":"https://github.com/tfkfan/mtls_jwt_demo","last_synced_at":"2026-05-02T05:41:45.922Z","repository":{"id":209691673,"uuid":"724721454","full_name":"tfkfan/MTLS_JWT_DEMO","owner":"tfkfan","description":"spring-boot mtls+stateless JWT authentication demo","archived":false,"fork":false,"pushed_at":"2024-04-01T13:23:05.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T17:47:04.830Z","etag":null,"topics":["jwt","mtls","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfkfan.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-11-28T16:55:48.000Z","updated_at":"2024-10-23T07:09:25.000Z","dependencies_parsed_at":"2024-04-01T14:45:38.375Z","dependency_job_id":null,"html_url":"https://github.com/tfkfan/MTLS_JWT_DEMO","commit_stats":null,"previous_names":["tfkfan/mtls_jwt_demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tfkfan/MTLS_JWT_DEMO","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfkfan%2FMTLS_JWT_DEMO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfkfan%2FMTLS_JWT_DEMO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfkfan%2FMTLS_JWT_DEMO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfkfan%2FMTLS_JWT_DEMO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfkfan","download_url":"https://codeload.github.com/tfkfan/MTLS_JWT_DEMO/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfkfan%2FMTLS_JWT_DEMO/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32524565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jwt","mtls","spring-boot"],"created_at":"2024-11-14T22:21:07.836Z","updated_at":"2026-05-02T05:41:45.907Z","avatar_url":"https://github.com/tfkfan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mutual TLS + JWT authentication spring boot example\n\nNot for development/production use\nThis project is designed to better understand how tls protocol \nand JWT tokens processing work. JWT/auth components, filters etc are already implemented in \nspring-boot-starter-oauth2-resource-server and spring-boot-starter-oauth2-client\n\n## Keys generation\n\nBecause MTLS is bi-directional secured communication \nwe need to generate keypairs for client and server both as well to encrypt each other's data\n\n### Ca keypair generation\n\n    sh generate-ca.sh\n\n### Server keypair, keystore, truststore generation\n\n    sh generate-ssl.sh ./ca server ssl-server.cnf\n\n### Client keypair, keystore, truststore generation \n\n    sh generate-ssl.sh ./ca client ssl-client.cnf\n\n## Spring boot application settings\n\nUse /config/application.yml with already defined settings for your app\nPut already generated keystore.jks and truststore.jks into src/main/resources\n\nRun from project root\n\n    mvn clean package\n    java -jar ./target/MTLS_JWT_DEMO-1.0-SNAPSHOT.jar\n\n\n## Requests\n\nFirst of all, we need to authenticate via JWT controller over HTTPs/MTLS and get bearer token:\n\n    curl -v --cert client.crt --key client.key --cacert ca.crt --header \"Content-Type: application/json\" --request POST https://localhost:8081/authenticate --data '{ \"username\":\"user1\", \"password\":\"password\"}'  \n\nThen you receive JWT token like\n    \n    eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ1c2VyMSIsImlhdCI6MTcwMTE5MDExMCwiZXhwIjoxNzAxMjA4MTEwfQ.3VOYkN5JbaxX7sxY5WV0L0wiaWhdIaXvY8BIV6dIdxnOMmh9R0UDFUIXXu10rIPyTfZmbCIdNYd3b5aWNyGL-g\n\nYou should put this token as bearer header to other further requests\n\nNow you can run test method\n\n     curl -v --cert client.crt --key client.key --cacert ca.crt --header \"Content-Type: application/json\" --header \"Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ1c2VyMSIsImlhdCI6MTcwMTE5MDI0OSwiZXhwIjoxNzAxMjA4MjQ5fQ.Nx-ZUTRaVMbonc_PrJro11Qi3Ab4PGmttbmfYA9baoQC67te07-j-iH7PjYbTV9JpaW2lw0C7_dI2PXBhoNvrA\" --request  GET https://localhost:8081/api/test \n\n## Security disable\n\nTo disable JWT security authentication set parameter\n\n    security.enabled: false\n\nin your config/application.yml\n\nTry to make following request\n\n    curl -v --cert client.crt --key client.key --cacert ca.crt --header \"Content-Type: application/json\" --header --request  GET https://localhost:8081/api/test \n\nAs you can see server and client have exchanged with public keys/certificates and the connection becames secured and encrypted on both sides\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfkfan%2Fmtls_jwt_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfkfan%2Fmtls_jwt_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfkfan%2Fmtls_jwt_demo/lists"}