Skip to content

Commit

Permalink
ability to add NAS Identifier header to radius request (#5465)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrGonzo authored and jefferai committed Oct 18, 2018
1 parent c15276c commit bad2f6d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions builtin/credential/radius/path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func pathConfig(b *backend) *framework.Path {
Default: 10,
Description: "RADIUS NAS port field (default: 10)",
},
"nas_identifier": &framework.FieldSchema{
Type: framework.TypeString,
Default: "",
Description: "RADIUS NAS Identifier field (optional)",
},
},

ExistenceCheck: b.configExistenceCheck,
Expand Down Expand Up @@ -110,6 +115,7 @@ func (b *backend) pathConfigRead(ctx context.Context, req *logical.Request, d *f
"dial_timeout": cfg.DialTimeout,
"read_timeout": cfg.ReadTimeout,
"nas_port": cfg.NasPort,
"nas_identifier": cfg.NasIdentifier,
},
}
return resp, nil
Expand Down Expand Up @@ -190,6 +196,13 @@ func (b *backend) pathConfigCreateUpdate(ctx context.Context, req *logical.Reque
cfg.NasPort = d.Get("nas_port").(int)
}

nasIdentifier, ok := d.GetOk("nas_identifier")
if ok {
cfg.NasIdentifier = nasIdentifier.(string)
} else if req.Operation == logical.CreateOperation {
cfg.NasIdentifier = d.Get("nas_identifier").(string)
}

entry, err := logical.StorageEntryJSON("config", cfg)
if err != nil {
return nil, err
Expand All @@ -209,6 +222,7 @@ type ConfigEntry struct {
DialTimeout int `json:"dial_timeout" structs:"dial_timeout" mapstructure:"dial_timeout"`
ReadTimeout int `json:"read_timeout" structs:"read_timeout" mapstructure:"read_timeout"`
NasPort int `json:"nas_port" structs:"nas_port" mapstructure:"nas_port"`
NasIdentifier string `json:"nas_identifier" structs:"nas_identifier" mapstructure:"nas_identifier"`
}

const pathConfigHelpSyn = `
Expand Down
3 changes: 3 additions & 0 deletions builtin/credential/radius/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ func (b *backend) RadiusLogin(ctx context.Context, req *logical.Request, usernam
packet := radius.New(radius.CodeAccessRequest, []byte(cfg.Secret))
UserName_SetString(packet, username)
UserPassword_SetString(packet, password)
if cfg.NasIdentifier != "" {
NASIdentifier_AddString(packet, cfg.NasIdentifier)
}
packet.Add(5, radius.NewInteger(uint32(cfg.NasPort)))

client := radius.Client{
Expand Down
6 changes: 5 additions & 1 deletion ui/app/models/auth-config/radius.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ export default AuthConfig.extend({
label: 'NAS Port',
}),

nasIdentifier: attr('string', {
label: 'NAS Identifier',
}),

fieldGroups: computed(function() {
const groups = [
{
default: ['host', 'secret'],
},
{
'RADIUS Options': ['port', 'nasPort', 'dialTimeout', 'unregisteredUserPolicies'],
'RADIUS Options': ['port', 'nasPort', 'nasIdentifier', 'dialTimeout', 'unregisteredUserPolicies'],
},
];
return fieldToAttrs(this, groups);
Expand Down

0 comments on commit bad2f6d

Please sign in to comment.