-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from linkernetworks/johnlin/verify-jwt
[Task] add verify jwt handler
- Loading branch information
Showing
11 changed files
with
179 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
- [Table of Contents](#table-of-contents) | ||
- [User](#user) | ||
- [Signup](#signup) | ||
- [Verify Token](#verify-token) | ||
- [Signin](#signin) | ||
- [Create User](#create-user) | ||
- [List User](#list-user) | ||
|
@@ -100,6 +101,22 @@ Response Data: | |
} | ||
``` | ||
|
||
### Verify Token | ||
|
||
**GET /v1/user/verify/auth** | ||
|
||
with a authorization JWT key | ||
|
||
``` | ||
Authorization: Bearer <MY_TOKEN> | ||
``` | ||
|
||
Response status code: | ||
|
||
when jwt is valid return status code 303 redirect to /v1/user/<id> | ||
when jwt is invalid return status code 401 | ||
|
||
|
||
### Signin | ||
|
||
**POST /v1/users/signin** | ||
|
@@ -125,7 +142,7 @@ Response Data: | |
|
||
### Create User | ||
|
||
**POST /v1/user** | ||
**POST /v1/users** | ||
|
||
Example: | ||
|
||
|
@@ -219,8 +236,25 @@ Response Data: | |
|
||
### Get User | ||
|
||
TODO | ||
**GET /v1/users/5b5b418c760aab15e771bde2** | ||
|
||
Response | ||
|
||
```json | ||
{ | ||
"id": "5b5b418c760aab15e771bde2", | ||
"loginCredential": { | ||
"username": "[email protected]", | ||
"password": "$2a$14$XO4OOUCaiTNQHm.ZTzHU5..WwtP2ec2Q2HPPQuMHP1WoXCjXiRrxa" | ||
}, | ||
"displayName": "John Doe", | ||
"role": "guest", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"phoneNumber": "0911111111", | ||
"createdAt": "2018-07-28T00:00:12.632011379+08:00" | ||
} | ||
``` | ||
|
||
### Delete User | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,9 @@ import ( | |
restful "github.com/emicklei/go-restful" | ||
"github.com/linkernetworks/vortex/src/entity" | ||
response "github.com/linkernetworks/vortex/src/net/http" | ||
"github.com/linkernetworks/vortex/src/serviceprovider" | ||
) | ||
|
||
func loginGetToken(sp *serviceprovider.Container, wc *restful.Container) (string, error) { | ||
service := newUserService(sp) | ||
wc.Add(service) | ||
|
||
func loginGetToken(wc *restful.Container) (string, error) { | ||
var resp response.ActionResponse | ||
userCred := entity.LoginCredential{ | ||
Username: "[email protected]", | ||
|