Skip to content

Commit 4b78232

Browse files
committed
添加支持 radius 的 nasip
1 parent 00c5425 commit 4b78232

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

server/dbdata/userauth_radius.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"net"
89
"reflect"
910
"time"
1011

@@ -15,6 +16,7 @@ import (
1516
type AuthRadius struct {
1617
Addr string `json:"addr"`
1718
Secret string `json:"secret"`
19+
Nasip string `json:"nasip"`
1820
}
1921

2022
func init() {
@@ -57,8 +59,22 @@ func (auth AuthRadius) checkUser(name, pwd string, g *Group) error {
5759
}
5860
// radius认证时,设置超时3秒
5961
packet := radius.New(radius.CodeAccessRequest, []byte(auth.Secret))
60-
rfc2865.UserName_SetString(packet, name)
61-
rfc2865.UserPassword_SetString(packet, pwd)
62+
err = rfc2865.UserName_SetString(packet, name)
63+
if err != nil {
64+
return fmt.Errorf("%s %s", name, "Radius set name 出现错误")
65+
}
66+
err = rfc2865.UserPassword_SetString(packet, pwd)
67+
if err != nil {
68+
return fmt.Errorf("%s %s", name, "Radius set pwd 出现错误")
69+
}
70+
if auth.Nasip != "" {
71+
nasip := net.ParseIP(auth.Nasip)
72+
err = rfc2865.NASIPAddress_Set(packet, nasip)
73+
if err != nil {
74+
return fmt.Errorf("%s %s", name, "Radius set nasip 出现错误")
75+
}
76+
}
77+
6278
ctx, done := context.WithTimeout(context.Background(), 3*time.Second)
6379
defer done()
6480
response, err := radius.Exchange(ctx, packet, auth.Addr)

web/src/pages/group/List.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@
298298
:rules="this.ruleForm.auth.type== 'radius' ? this.rules['auth.radius.secret'] : [{ required: false }]">
299299
<el-input v-model="ruleForm.auth.radius.secret" placeholder=""></el-input>
300300
</el-form-item>
301+
<el-form-item label="Nasip" prop="auth.radius.nasip">
302+
<el-input v-model="ruleForm.auth.radius.nasip" placeholder=""></el-input>
303+
</el-form-item>
301304
</template>
302305

303306
<template v-if="ruleForm.auth.type == 'ldap'">
@@ -547,7 +550,7 @@ export default {
547550
maxRouteRows: 2500,
548551
defAuth: {
549552
type: 'local',
550-
radius: {addr: "", secret: ""},
553+
radius: {addr: "", secret: "", nasip: ""},
551554
ldap: {
552555
addr: "",
553556
tls: false,

0 commit comments

Comments
 (0)