Skip to content

Commit

Permalink
Fix compile after dep update
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Sep 5, 2017
1 parent b0e29bb commit 4f3dfb2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion builtin/credential/radius/path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 18 additions & 8 deletions builtin/credential/radius/path_login.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package radius

import (
"context"
"fmt"
"net"
"strconv"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion physical/cockroachdb/cockroachdb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cockroachdb

import (
"context"
"database/sql"
"fmt"
"sort"
Expand Down Expand Up @@ -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)
})
}
Expand Down
6 changes: 2 additions & 4 deletions website/source/api/auth/radius/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -236,4 +234,4 @@ $ curl \
"lease_duration": 7200,
"renewable": true
}
```
```

0 comments on commit 4f3dfb2

Please sign in to comment.