rk-boot
rk-boot copied to clipboard
how can I find the jwt endpoints?
Describe the bug A clear and concise description of what the bug is. Hi,
First of all, really nice work done here.
After setting up jwt middleware I am unable to acess sw even when ignore is set to /sw, how can I know jwt endpoints to get access token?
To Reproduce Steps to reproduce the behavior:
gin:
- name: greeter # Required
port: 8080 # Required
enabled: true # Required
commonService:
enabled: true # Optional, default: false
sw:
enabled: true # Optional, default: false
docs:
enabled: true # Optional, default: false
middleware:
jwt:
enabled: true # Optional, default: false
ignorePrefix: # Optional, default: []
- "/sw"
Expected behavior after ignoring /sw I should be able to access sw and retrieve endpoints to get jwt token
Desktop (please complete the following information):
- OS: Linux
- Brave
- Version
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version v2.2.3
@MushiTheMoshi Hi, there are couple of steps we need to do if we hope to authorize API with JWT in swagger.
I created a demo at demo
Steps needs to follow for JWT in Swagger
- Swag comments which enables JWT security in code.
- Implement Login() handler which will generate custom JWT token for requests
- Authorize with JWT in swagger UI.
Short demo
Please refer to code at demo
boot.yaml
---
gin:
- name: greeter
port: 8080
enabled: true
sw:
enabled: true
middleware:
jwt:
enabled: true
ignore:
- "/v1/login"
- "/sw"
main.go
Start server
go run main.go
Access swagger UI
http://localhost:8080/sw
Login
Authorize JWT in Swagger
Copy returned JWT token and authorize JWT
Send /v1/whoami
Thank you so much the detailed explanation, I will test and let you know.
Hi there,
You are awesome! it worked like a charm!
Thank you so much for the example!
I am a newbie in terms of development, I really like the tool though I am not sure how to use in a structured application like a clean or hexagonal layout, do you think you can provide a quick example of it?
Thanks in advance for the help!
Regards, Julio