Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrenerd/gin-multifactor-authentication
Gin Multifactor Authentication
https://github.com/andrenerd/gin-multifactor-authentication
1fa 2fa aip authentication email gin golang mfa mobile passcode password phonew pin token two-factor-authentication web
Last synced: about 1 month ago
JSON representation
Gin Multifactor Authentication
- Host: GitHub
- URL: https://github.com/andrenerd/gin-multifactor-authentication
- Owner: andrenerd
- Created: 2021-01-09T00:58:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-05T23:11:41.000Z (almost 4 years ago)
- Last Synced: 2023-12-21T05:20:45.410Z (about 1 year ago)
- Topics: 1fa, 2fa, aip, authentication, email, gin, golang, mfa, mobile, passcode, password, phonew, pin, token, two-factor-authentication, web
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gin Multifactor Authentication
v 0.0.1
Flexible authentication for web, mobile, desktop and hybrid apps. Can be used for 1fa, 2fa and mfa scenarios. Easily configurable and extendable with new authentication methods, called `services`. All authenticaton scenarios, called `flows`, are based on `identifiers` and `secrets`, which can be used or not used in multiple combinations:
- username, email, phone, ...
- password, passcode (aka one-time pass or token), hardcode (aka device or card id), ...Full list of supported services (devices):
- Email (soon)
- Phone (as Sms)
- WhatsApp (soon)
- Google Authenticator
- Microsoft Authenticator
- Authy, andOTP, etc
- Yubikey (soon)
- ...add yoursand service providers:
- Twilio
- Vonage (Nexmo) (soon)
- Amazon SNS (soon)
- ...add yours### Usage
See an example app in the `/example` folder.```
// Init with specific flow(s):
// authenticate user if all (username, password, passcode) params are valid
auth := multauth.Auth{
Flows: []multauth.Flow{{"Username", "Password", "Passcode"}},
}app := gin.Default()
app.POST("/signin", func(c *gin.Context) {
// ...Grab params from the context and store them in the "data" maperr := auth.Authenticate(map[string]interface{}{
"Username": data["username"],
"Password": data["password"],
"Passcode": data["passcode"], // with Google Authenticator or so
}, user)if err == nil {
c.JSON(200, gin.H{
"message": "Welcome " + user.Username,
"token": "YOUR_JWT_TOKEN",
})
}
})app.Run()
```