This is a simple Golang server with JWT auth.
HTTP-ROUTER - install: "go get -u github.com/gorilla/mux"
JWT - install: "go get github.com/dgrijalva/jwt-go"
pq - install: "go get github.com/lib/pq"
postman - for testing endpoints
Go-Spew - install: "go get -u github.com/davecgh/go-spew/spew" Styles JSON returned
Bcrypt - "import "golang.org/x/crypto/bcrypt"
- JWT stands for JSON Web Token
- JWT is a means of exchanging information between two parties
- Digitally signed
- Structure of a JWT: {Base64 encoded Header}.{Base64 encoded Payload}.{Signature}
- header: Algorithm & Token Type
- payload: Carry claims
- Contains data such as User information token expiry etc..
- Three types of claims: Registered, Public, and Private
- signature: Computed from the Header, Payload and a Secret
- An algorithm to generate the signature
- Digitally signed using a secret string only known to the developer
-
Creating user table
create table users ( id serial primary key, email text not null unique, password text not null );
-
Creating a user record
insert into users (email, password) values (‘someemail.com’, ‘somePassword’)
-
Selecting users
select * from users;