csyezheng / a2fa Goto Github PK
View Code? Open in Web Editor NEWa2fa is a command line tool for generating and validating one-time password. Its purpose is to get rid of phones and be able to authenticate easily.
License: Apache License 2.0
a2fa is a command line tool for generating and validating one-time password. Its purpose is to get rid of phones and be able to authenticate easily.
License: Apache License 2.0
One-time passwords can be easily calculated if the secret key is compromised
It is recommend to encrypt the shared secrets
Currently secret keys are stored in clear text in the database.
Storing the keys securely by encrypting them with tamper-resistant hardware encryption
Using the user’s password to encrypt the secret keys
a2fa generate "sjty rbgo 56og 37kj sz6s ry2c t3l3 pm5p"
输出
Code: 358511
谷歌身份验证器同一时间是 919019
a2fa generate xxxxxxxxx
003269
3269
Run with argument "list" multiple times
All records displayed
linux Ubuntu / Windows 11
Proposed fix: (confirmed to work locally)
Alter cmd/commands/list.go listAccounts
When the append(result, otpView{...}) line of code is run concurrently from multiple goroutines, they all try to write to the result slice at the same time which results in some writes being lost.
Solution: synchronize access to the result slice by wrapping the section in a mutex
example:
var wg sync.WaitGroup
var mu sync.Mutex
for _, account := range accounts {
wg.Add(1)
go func(account models.Account) {
defer wg.Done()
code, err := account.OTP()
if err != nil {
log.Printf("%s %s generate code error%s\n", account.AccountName, account.Username, err)
} else {
mu.Lock() // start critical section
result = append(result, otpView{
accountName: account.AccountName,
userName: account.Username,
code: code,
})
mu.Unlock() // end critical section
}
}(account)
}...`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.