-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
77 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
> Developed by OpenMix: [https://openmix.org](https://openmix.org/mix-go) | ||
## Mix Authenticator | ||
|
||
Install | ||
|
||
``` | ||
go get github.com/mix-go/authenticator@latest | ||
``` | ||
|
||
Generate Secret | ||
|
||
```go | ||
secret := authenticator.GenerateSecret() | ||
``` | ||
|
||
Generate Code | ||
|
||
```go | ||
code := authenticator.GenerateToken(secret) | ||
``` | ||
|
||
Verify Code | ||
|
||
```go | ||
ok := authenticator.VerifyToken(secret, code) | ||
// or | ||
ok := authenticator.VerifyTokenCustom(secret, code, 60) | ||
``` | ||
|
||
Generate Url | ||
|
||
```go | ||
uri := authenticator.GenerateTotpUri("Foo", "bar", secret) | ||
// or | ||
url := authenticator.GenerateQRCodeGoogleUrl("Foo", "bar", secret) | ||
``` | ||
|
||
## License | ||
|
||
Apache License Version 2.0, http://www.apache.org/licenses/ |
2 changes: 1 addition & 1 deletion
2
src/googleauthenticator/authenticator.go → src/authenticator/authenticator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package googleauthenticator | ||
package authenticator | ||
|
||
import ( | ||
"crypto/rand" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package authenticator_test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/mix-go/authenticator" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestVerifyToken(t *testing.T) { | ||
a := assert.New(t) | ||
|
||
secret := authenticator.GenerateSecret() | ||
code := authenticator.GenerateToken(secret) | ||
ok := authenticator.VerifyToken(secret, code) | ||
uri := authenticator.GenerateTotpUri("foo", "bar", secret) | ||
url := authenticator.GenerateQRCodeGoogleUrl("foo", "bar", secret) | ||
fmt.Printf("%v\n%s\n%s\n", ok, uri, url) | ||
|
||
a.Equal(ok, true) | ||
} | ||
|
||
func TestPHPVerifyToken(t *testing.T) { | ||
a := assert.New(t) | ||
|
||
secret := "OQB6ZZGYHCPSX4AK" | ||
code := authenticator.GenerateToken(secret) | ||
ok := authenticator.VerifyToken(secret, code) | ||
uri := authenticator.GenerateTotpUri("foo", "bar", secret) | ||
url := authenticator.GenerateQRCodeGoogleUrl("foo", "bar", secret) | ||
fmt.Printf("%v\n%s\n%s\n", ok, uri, url) | ||
|
||
a.Equal(ok, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/mix-go/googleauthenticator | ||
module github.com/mix-go/authenticator | ||
|
||
go 1.20 | ||
|
||
|
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.