mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
First pass authorization parser
This commit is contained in:
@@ -20,8 +20,26 @@ import (
|
||||
|
||||
// For multiple accounts/users.
|
||||
type User struct {
|
||||
Username string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
Permissions Authorization `json:"permissions"`
|
||||
MaxConns int `json:"max_connections"`
|
||||
MaxSubs int `json:"max_subscriptions"`
|
||||
}
|
||||
|
||||
// Authorization are the allowed subjects on a per
|
||||
// publish or subscribe basis.
|
||||
type Authorization struct {
|
||||
pub *Permission `json:"publish"`
|
||||
sub *Permission `json:"subscribe"`
|
||||
}
|
||||
|
||||
// Permission is for describing the subjects and rate limits
|
||||
// that an account connection can publish or subscribe to and
|
||||
// what limits if any exist for message and/or byte rates.
|
||||
type Permission struct {
|
||||
Subjects []string `json:"subjects"`
|
||||
// FIXME(dlc) figure out rates.
|
||||
}
|
||||
|
||||
// Options block for gnatsd server.
|
||||
|
||||
@@ -397,3 +397,11 @@ func TestMultipleUsersConfig(t *testing.T) {
|
||||
}
|
||||
processOptions(opts)
|
||||
}
|
||||
|
||||
func TestAuthorizationConfig(t *testing.T) {
|
||||
opts, err := ProcessConfigFile("./configs/authorization.conf")
|
||||
if err != nil {
|
||||
t.Fatalf("Received an error reading config file: %v\n", err)
|
||||
}
|
||||
processOptions(opts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user