diff --git a/builtin/credential/radius/path_config.go b/builtin/credential/radius/path_config.go index 2eaac22bc791..7d4bc8b22ad6 100644 --- a/builtin/credential/radius/path_config.go +++ b/builtin/credential/radius/path_config.go @@ -39,7 +39,7 @@ func pathConfig(b *backend) *framework.Path { "read_timeout": &framework.FieldSchema{ Type: framework.TypeDurationSecond, Default: 10, - Description: "Number of seconds before response times out (default: 10)", + Description: "Number of seconds before response times out (default: 10). Note: kept for backwards compatibility, currently unused.", }, "nas_port": &framework.FieldSchema{ Type: framework.TypeInt, diff --git a/builtin/credential/radius/path_login.go b/builtin/credential/radius/path_login.go index 438939a9b747..f3f8c9df23ab 100644 --- a/builtin/credential/radius/path_login.go +++ b/builtin/credential/radius/path_login.go @@ -1,6 +1,7 @@ package radius import ( + "context" "fmt" "net" "strconv" @@ -51,12 +52,12 @@ func (b *backend) pathLogin( if username == "" { username = d.Get("urlusername").(string) if username == "" { - return logical.ErrorResponse("username cannot be emtpy"), nil + return logical.ErrorResponse("username cannot be empty"), nil } } if password == "" { - return logical.ErrorResponse("password cannot be emtpy"), nil + return logical.ErrorResponse("password cannot be empty"), nil } policies, resp, err := b.RadiusLogin(req, username, password) @@ -123,15 +124,24 @@ func (b *backend) RadiusLogin(req *logical.Request, username string, password st hostport := net.JoinHostPort(cfg.Host, strconv.Itoa(cfg.Port)) packet := radius.New(radius.CodeAccessRequest, []byte(cfg.Secret)) - packet.Add("User-Name", username) - packet.Add("User-Password", password) - packet.Add("NAS-Port", uint32(cfg.NasPort)) + usernameAttr, err := radius.NewString(username) + if err != nil { + return nil, nil, err + } + passwordAttr, err := radius.NewString(password) + if err != nil { + return nil, nil, err + } + packet.Add(1, usernameAttr) + packet.Add(2, passwordAttr) + packet.Add(5, radius.NewInteger(uint32(cfg.NasPort))) client := radius.Client{ - DialTimeout: time.Duration(cfg.DialTimeout) * time.Second, - ReadTimeout: time.Duration(cfg.ReadTimeout) * time.Second, + Dialer: net.Dialer{ + Timeout: time.Duration(cfg.DialTimeout) * time.Second, + }, } - received, err := client.Exchange(packet, hostport) + received, err := client.Exchange(context.Background(), packet, hostport) if err != nil { return nil, logical.ErrorResponse(err.Error()), nil } diff --git a/physical/cockroachdb/cockroachdb.go b/physical/cockroachdb/cockroachdb.go index 1765e68d59b7..395c2da2bbf4 100644 --- a/physical/cockroachdb/cockroachdb.go +++ b/physical/cockroachdb/cockroachdb.go @@ -1,6 +1,7 @@ package cockroachdb import ( + "context" "database/sql" "fmt" "sort" @@ -204,7 +205,7 @@ func (c *CockroachDBBackend) Transaction(txns []physical.TxnEntry) error { c.permitPool.Acquire() defer c.permitPool.Release() - return crdb.ExecuteTx(c.client, func(tx *sql.Tx) error { + return crdb.ExecuteTx(context.Background(), c.client, nil, func(tx *sql.Tx) error { return c.transaction(tx, txns) }) } diff --git a/website/source/api/auth/radius/index.html.md b/website/source/api/auth/radius/index.html.md index 23d152001441..b1a6a02e172b 100644 --- a/website/source/api/auth/radius/index.html.md +++ b/website/source/api/auth/radius/index.html.md @@ -35,9 +35,7 @@ RADIUS. - `unregistered_user_policies` `(string: "")` - A comma-separated list of policies to be granted to unregistered users. - `dial_timeout` `(integer: 10)` - Number of second to wait for a backend - connection before timing out. Defaults is 10. -- `read_timeout` `(integer: 10)` - Number of second to wait for a backend - response before timing out. Defaults is 10. + connection before timing out. Default is 10. - `nas_port` `(integer: 10)` - The NAS-Port attribute of the RADIUS request. Defaults is 10. @@ -236,4 +234,4 @@ $ curl \ "lease_duration": 7200, "renewable": true } - ``` \ No newline at end of file + ```