https://github.com/stremovskyy/golaraauth
Laravel JWT Auth implementation on GO
https://github.com/stremovskyy/golaraauth
golang golang-library golang-package laravel laravel-auth laravel-authentication
Last synced: 2 months ago
JSON representation
Laravel JWT Auth implementation on GO
- Host: GitHub
- URL: https://github.com/stremovskyy/golaraauth
- Owner: stremovskyy
- License: apache-2.0
- Created: 2019-02-14T15:22:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-13T13:30:38.000Z (over 1 year ago)
- Last Synced: 2025-02-24T10:06:52.079Z (2 months ago)
- Topics: golang, golang-library, golang-package, laravel, laravel-auth, laravel-authentication
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Golaraauth
golaraauth is a simple authentication provider written in GO used in [Laravel](https://laravel.com/) 5.1+.
with this package you can verify the token string that generated by laravel and return the user model that used in laravel auth provider.
## Installation
```bash
go get github.com/stremovskyy/golaraauth
```## Usage
### laravel model
first of all you need to create a model that used in laravel with auth provider```go
package maintype DBModel struct {
ID int64
TokenID string
CreatedAt string
UpdatedAt string
}
```
this model will be used in the VerifyTokenString method to return the user model```go
package mainimport (
"fmt"
"github.com/stremovskyy/golaraauth"
)type DBModel struct {
ID int64
TokenID string
CreatedAt string
UpdatedAt string
}func main() {
model := &DBModel{}dbConfig := golaraauth.DbConfig{
HostName: "127.0.0.1",
Port: "3306",
Username: "root",
Password: "123698741",
DbName: "123456",
TokensTable: "user_tokens",
TokensTableCol: "token_id",
}config := golaraauth.AuthConfig{
DbConfig: dbConfig,
PrivateKey: privKey,
PublicKey: pubkey,
}a := golaraauth.LaravelAuthenticator{}
err := a.New(config)
if err != nil {
panic(err)
}defer a.CloseDBConnection()
b, err := a.VerifyTokenString(tokenString, model)
if err != nil {
panic(err)
}println(b)
}
```## License
[MIT](https://choosealicense.com/licenses/mit/)
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## Authors
* **Anton Stremovskyy** - *Initial work* - [stremovskyy](https://github.com/stremovskyy)
## Acknowledgements
- [Laravel](https://laravel.com/)
- [jwt-go](https://github.com/golang-jwt/jwt)
- [gorm](https://gorm.io/gorm)