Skip to content

Commit

Permalink
feat: Add system user authentication and accounting settings resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic authored and vaerh committed Jan 5, 2024
1 parent f889b7b commit 1899983
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/resources/routeros_system_user_aaa/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_system_user_aaa.settings .
3 changes: 3 additions & 0 deletions examples/resources/routeros_system_user_aaa/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "routeros_system_user_aaa" "settings" {
use_radius = true
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func Provider() *schema.Provider {
"routeros_system_ntp_server": ResourceSystemNtpServer(),
"routeros_system_scheduler": ResourceSystemScheduler(),
"routeros_system_user": ResourceUser(),
"routeros_system_user_aaa": ResourceUserAaa(),
"routeros_system_user_group": ResourceUserGroup(),
"routeros_system_user_settings": ResourceSystemUserSettings(),

Expand Down
68 changes: 68 additions & 0 deletions routeros/resource_system_user_aaa.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package routeros

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

/*
{
"accounting": "true",
"default-group": "read",
"exclude-groups": "full",
"interim-update": "0s",
"use-radius": "false"
}
*/

// https://help.mikrotik.com/docs/display/ROS/User#User-RemoteAAA
func ResourceUserAaa() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/user/aaa"),
MetaId: PropId(Id),

"accounting": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "An option that enables accounting for users.",
},
"default_group": {
Type: schema.TypeString,
Optional: true,
Default: "read",
Description: "The user group that is used by default for users authenticated via a RADIUS server.",
},
"exclude_groups": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "A set of groups that are not allowed for users authenticated by RADIUS.",
},
"interim_update": {
Type: schema.TypeString,
Optional: true,
Default: "0s",
Description: "Interval between scheduled RADIUS Interim-Update messages.",
DiffSuppressFunc: TimeEquall,
},
"use_radius": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "An option whether to use RADIUS server.",
},
}

return &schema.Resource{
CreateContext: DefaultSystemCreate(resSchema),
ReadContext: DefaultSystemRead(resSchema),
UpdateContext: DefaultSystemUpdate(resSchema),
DeleteContext: DefaultSystemDelete(resSchema),

Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: resSchema,
}
}

0 comments on commit 1899983

Please sign in to comment.