Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thegeorgenikhil/go-gin-sveltekit-jwt-cookie-example
An example of how to use JWT authentication with Go Gin and SvelteKit using cookies(*inside SvelteKit*)
https://github.com/thegeorgenikhil/go-gin-sveltekit-jwt-cookie-example
authentication cookie golang sveltekit
Last synced: 14 days ago
JSON representation
An example of how to use JWT authentication with Go Gin and SvelteKit using cookies(*inside SvelteKit*)
- Host: GitHub
- URL: https://github.com/thegeorgenikhil/go-gin-sveltekit-jwt-cookie-example
- Owner: thegeorgenikhil
- Created: 2024-01-25T04:38:39.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-25T04:48:11.000Z (12 months ago)
- Last Synced: 2024-11-11T06:06:21.214Z (2 months ago)
- Topics: authentication, cookie, golang, sveltekit
- Language: Go
- Homepage:
- Size: 57.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Gin + SvelteKit - JWT Authentication Example using Cookies
An example of how to use JWT authentication with Go Gin and SvelteKit using cookies. The server returns the jwt token in response body and inside SvelteKit we store it in a cookie. The cookie is sent with every request to the server(SvelteKit) when using SSR.
## Setup
### Install dependencies
```bash
# Installing the node dependencies for the frontend
make install_frontend# Installing the go dependencies for the server
make install_server
```### Start the server
```bash
make server
```### Start the client
```bash
make frontend
```## Routes
| Route | Method | Request Body | Description |
| --------------- | ------ | -------------------- | ----------------------------------------------------------------------------- |
| /auth/login | `POST` | `email` + `password` | Login route, returns a jwt `token` + `message` |
| /auth/signup | `POST` | `email` + `password` | Signup route, returns a jwt `token` + `message` |
| /user/get-my-id | `GET` | `none` | Returns the `id` of the user, needs `Authorization` header with the jwt token |