mirror of
https://github.com/1f349/violet.git
synced 2024-11-25 04:41:34 +00:00
31 lines
606 B
Go
31 lines
606 B
Go
package fake
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"crypto/rsa"
|
|
"github.com/MrMelon54/mjwt"
|
|
"github.com/MrMelon54/mjwt/auth"
|
|
"github.com/MrMelon54/mjwt/claims"
|
|
"time"
|
|
)
|
|
|
|
var SnakeOilProv = GenSnakeOilProv()
|
|
|
|
func GenSnakeOilProv() mjwt.Signer {
|
|
key, err := rsa.GenerateKey(rand.Reader, 1024)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return mjwt.NewMJwtSigner("violet.test", key)
|
|
}
|
|
|
|
func GenSnakeOilKey(perm string) string {
|
|
p := claims.NewPermStorage()
|
|
p.Set(perm)
|
|
val, err := SnakeOilProv.GenerateJwt("abc", "abc", nil, 5*time.Minute, auth.AccessTokenClaims{Perms: p})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return val
|
|
}
|