Categorygithub.com/yahya077/otp-golang
repositorypackage
1.0.3
Repository: https://github.com/yahya077/otp-golang.git
Documentation: pkg.go.dev

# README

otp-golang

This is an OTP Auth package for GOLang.

Screen Shot 2022-11-08 at 22 44 13

ā­ļø 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

TitleRouteMethodHandlerMiddlewareCustomizableDescription
OTP/auth/otpPOSTOtpHandlernoneāœ“Sends OTP to user
Login/auth/loginPOSTLoginHandlernoneāœ“Returns Bearer token
Register/auth/registerPOSTRegisterHandlerAuthMiddlewareāœ“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

MiddlewareDescription
authApp.Config.AuthMiddleware Looks for Bearer token

šŸ“«Ā  Have a question? Want to chat? Ran into a problem?

Website yahyahindioglu.com

LinkedIn Account