summaryrefslogtreecommitdiffstats
path: root/back/auth/auth.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-03-14 11:23:50 -0400
committerSam Anthony <sam@samanthony.xyz>2026-03-14 11:23:50 -0400
commit700096b078f6e16f2c5c967ea140f0b93e799986 (patch)
treee1d9965e9bf09ebe01a96d8faa6d2bc027e6984c /back/auth/auth.go
parent7d622695ae19e518fded6aa5fbf001dae4652211 (diff)
downloadbuth-700096b078f6e16f2c5c967ea140f0b93e799986.zip
authfs: rewrite with Harvey-OS/ninep, implement Rattachharveyos
Diffstat (limited to 'back/auth/auth.go')
-rw-r--r--back/auth/auth.go36
1 files changed, 28 insertions, 8 deletions
diff --git a/back/auth/auth.go b/back/auth/auth.go
index 5685001..9625cc7 100644
--- a/back/auth/auth.go
+++ b/back/auth/auth.go
@@ -1,17 +1,37 @@
package auth
-import "fmt"
+import (
+ "fmt"
+ "time"
+)
const (
- // Maximum number of bytes in a Username.
- MaxUsernameSize = 64
+ // Maximum number of bytes in a username.
+ MaxUnameSize = 64
+
+ // Number of bytes in a session ID.
+ SessIdSize = 32
+ SessTimeout = 1 * time.Hour
)
-type Username string
+// User name.
+type Uname string
+
+// Session ID.
+type SessId [SessIdSize]byte
+
+func ParseUname(s string) (Uname, error) {
+ if len(s) > MaxUnameSize {
+ return "", fmt.Errorf("username longer than %d bytes: %q", MaxUnameSize, s)
+ }
+ return Uname(s), nil
+}
-func ValidiateUsername(s string) (Username, error) {
- if len(s) > MaxUsernameSize {
- return "", fmt.Errorf("username longer than %d bytes: %q", MaxUsernameSize, s)
+func ParseSessId(s string) (SessId, error) {
+ if len(s) != SessIdSize {
+ return SessId{}, fmt.Errorf("wrong session ID size: %d (want %d): %q", len(s), SessIdSize, s)
}
- return Username(s), nil
+ var id SessId
+ copy(id[:], s)
+ return id, nil
}