# AWS spring security jwt token project https://rpubs.com/empireisme # 該project架構    > 圖片來自參考影片的截圖 # 該project我的改善和學習點 1. 將它部署上aws雲端 2. 了解如何產生和使用jwt token,並且新增其他不需要登入就可以使用的端點 # 該Project 使用方式 可以先測試這個端點: http://jwttoken-env.eba-fnz3ccbr.us-east-1.elasticbeanstalk.com/testApi 直接在瀏覽器貼上就可以獲得字串資料 測試均須使用postman,測試流程是 1. 註冊 2. 透過帳號密碼取得jwt token 3. 使用getmapping 攜帶 jwt token後訪問對應的端點 ## 1.先註冊 在postman上面使用 post 方法 http://jwttoken-env.eba-fnz3ccbr.us-east-1.elasticbeanstalk.com/register 在body中填入下面資訊,記得選擇raw和json ``` { "username":"yourusername", "password":"yourpassword" } ```  ## 2.透過登入取得jwt token 在postman上面使用 post 方法 http://jwttoken-env.eba-fnz3ccbr.us-east-1.elasticbeanstalk.com/authenticate 在body中填入下面資訊,記得選擇raw和json ``` { "username":"yourusername", "password":"yourpassword" } ``` > 基本上兩次註冊和登入在body輸入的資訊要是一樣的,差別只在url的endpoint不同  並且在登入時,你會取得 jwt token,可以用在訪問 hello 端點 ## 3. 使用getmapping 攜帶 jwt token後訪問對應的端點 http://jwttoken-env.eba-fnz3ccbr.us-east-1.elasticbeanstalk.com/hello 在postman上面使用 get 方法 在header當中 KEY:Authorization VALUE:Bearer jwttoken > Bearer跟jwttoken當中要有一個空格  # 參考資料 本次project 主要參考來自 https://www.javainuse.com/spring/boot-jwt https://cyberguard.in/microservice-authorization-by-using-jwt/ # 為了完成部署的設定 ``` jwt.secret=javainuse spring.datasource.url=jdbc:mysql://mike.c24rbcnlh1qu.us-east-1.rds.amazonaws.com/mike?serverTimezone=UTC spring.datasource.username=root spring.datasource.password=12111211 spring.datasource.platform=mysql spring.jpa.hibernate.ddl-auto=update spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect server.port=5000 spring.jpa.properties.max_allowed_packet=2000 ``` > port要改成5000才不會有502錯誤
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up