Fix compile after dep update
This commit is contained in:
parent
0665badfdd
commit
44bf03e3b6
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
```
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue