Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobaccan committed Mar 11, 2022
2 parents 8d60557 + 7b3536b commit 4a8d80c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ A simple library to work with JSON Web Token and JSON Web Signature for Harbour
Package is available on [GitHub](https://github.com/matteobaccan/HarbourJwt/blob/main/lib/jwt.hrb),

```shell
wget https://github.com/matteobaccan/HarbourJwt/blob/main/lib/jwt.hrb
wget https://github.com/matteobaccan/HarbourJwt/blob/main/lib/jwt.hrb?raw=true
```

## Documentation
JWT is a class library that can allow you to generate and validate JWT tokens

### Token generation
For create a token you must
To create a token you must

1. Load jwt,hrb library

Expand All @@ -33,7 +33,7 @@ LOCAL cToken
oJWT := &("JWT():new()")
```

3. Configure a valid header, setting Type = JWT and an available Algorithm. At the moment the Algorithms available are: HS256, HS384 and HS512
3. Configure a valid header, setting Type = JWT and an available Algorithm. At the moment the Algorithms available are: HS256, HS384, and HS512

```
// Header
Expand All @@ -53,7 +53,7 @@ METHOD SetIssuedAt( nIssuedAt )
METHOD SetJWTId( cJWTId )
```

A simple payload can be formed by: Subject, Name and IssueAt
A simple payload can be formed by: Subject, Name, and IssueAt

```
// Payload
Expand Down Expand Up @@ -81,7 +81,7 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4
```

### Token verification
Token verifications are also symple
Token verifications are also simple

1. Load jwt.hrb library

Expand All @@ -104,12 +104,12 @@ oJWT := &("JWT():new()")
oJWT:Decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ik1hdHRlbyBCYWNjYW4iLCJpYXQiOjE1MTYyMzkwMjJ9.YR8QF52kgj0owYlP9TkEy_lNhC-Qdq38tqNNNqpvpK0", "MySecret")
```

Decode return a .T. if token is valid. Other wise with
Decode return a .T. if the token is valid. Otherwise with

```
oJWT:GetError()
```
You can get the decode error
you can get the decode error

## Contribution
Feel free to update this code with new PR
Feel free to update this code with a new PR

0 comments on commit 4a8d80c

Please sign in to comment.