2023-07-12 16:55:09 +01:00
|
|
|
package fake
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"crypto/rsa"
|
2023-10-29 12:55:19 +00:00
|
|
|
"github.com/1f349/mjwt"
|
|
|
|
"github.com/1f349/mjwt/auth"
|
|
|
|
"github.com/1f349/mjwt/claims"
|
2023-07-12 16:55:09 +01:00
|
|
|
"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
|
|
|
|
}
|