mirror of
https://github.com/gl-inet/glkvm-cloud.git
synced 2026-09-18 08:35:13 +00:00
a5bce3b289
Complete the initial framework for resource-based permission management, providing the foundation for role-based access control and future permission extensions. Signed-off-by: GL.iNet-Yongping.Xie <yongping.xie@gl-inet.com>
17 lines
312 B
Go
Executable File
17 lines
312 B
Go
Executable File
package randtoken
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
)
|
|
|
|
// New returns a high-entropy random token (URL-safe).
|
|
// 32 bytes => 256-bit.
|
|
func New() (string, error) {
|
|
b := make([]byte, 32)
|
|
if _, err := rand.Read(b); err != nil {
|
|
return "", err
|
|
}
|
|
return base64.RawURLEncoding.EncodeToString(b), nil
|
|
}
|