# README
otp-golang
This is an OTP Auth package for GOLang.

āļø This package is still in development. I welcome suggestions for changes that will bring it closer to compliance without overly complicating the code, or useful test cases to add to the test suite.
ā”ļø Quick Start
go get -u github.com/yahya077/otp-golang
š Prebuild Handlers
Note: There is an available documentation with Postman API Documentation
Title | Route | Method | Handler | Middleware | Customizable | Description |
---|---|---|---|---|---|---|
OTP | /auth/otp | POST | OtpHandler | none | ā | Sends OTP to user |
Login | /auth/login | POST | LoginHandler | none | ā | Returns Bearer token |
Register | /auth/register | POST | RegisterHandler | AuthMiddleware | ā | Registers user by User Repository |
š” Usage
Note: Example usage on otp-golang-example
// create instance off Auth
authApp := auth.New(app, database.Postgresql.DB, auth.Config{})
// set sms provider for sending otp code to phone number
authApp.SetSmsProvider(smsProvider.MockedSmsSenderProviderClient{})
// set your custom user model as a subject for verify, insert and register
authApp.SetUserRepository(repository.UserRepository{})
// finally initialize the auth app
authApp.Initialize()
// You can use middleware as shown below
app.Get("/test-auth", authApp.Config.AuthMiddleware, func(ctx *fiber.Ctx) error {
return ctx.JSON("authorized")
})
𧬠Auth Middleware
This middleware will be ready after initialization of Auth. You can override Middleware if you want to
Middleware | Description |
---|---|
authApp.Config.AuthMiddleware | Looks for Bearer token |
š«Ā Have a question? Want to chat? Ran into a problem?
Website yahyahindioglu.com
LinkedIn Account
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
No description provided by the author