Files
Andrew Martinez 880f628aac allows JWTs to be sent for authenticatoin and API requests
- authentication abstractions from edge-api
- adds support for API Session certificates on non-cert auth
- adds example
- add caPool cfg support
- adds example go.work
- converts sync.Maps to typed concurrent maps
- adds readme for jwtchat example
- update git ignore to only ignore root go.work
2023-03-17 15:38:50 -04:00

62 lines
1013 B
Go

package storage
import (
"crypto/rsa"
)
type User struct {
ID string
Username string
Password string
FirstName string
LastName string
Email string
}
type Service struct {
keys map[string]*rsa.PublicKey
}
type UserStore interface {
GetUserByID(string) *User
GetUserByUsername(string) *User
ExampleClientID() string
}
type userStore struct {
users map[string]*User
}
func NewUserStore() UserStore {
return userStore{
users: map[string]*User{
"id1": {
ID: "id1",
Username: "test1",
Password: "test1",
FirstName: "Test",
LastName: "User",
Email: "[email protected]",
},
},
}
}
// ExampleClientID is only used in the example server
func (u userStore) ExampleClientID() string {
return "service"
}
func (u userStore) GetUserByID(id string) *User {
return u.users[id]
}
func (u userStore) GetUserByUsername(username string) *User {
for _, user := range u.users {
if user.Username == username {
return user
}
}
return nil
}