Skip to content

Commit

Permalink
feat: Add 802.1X client resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic authored and vaerh committed Nov 10, 2023
1 parent 44e0a40 commit db76369
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/resources/routeros_interface_dot1x_client/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/interface/dot1x/client get [print show-ids]]
terraform import routeros_interface_dot1x_client.ether2 *1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "routeros_interface_dot1x_client" "ether2" {
eap_methods = "eap-peap,eap-mschapv2"
identity = "router"
interface = "ether2"
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func Provider() *schema.Provider {
"routeros_interface_bridge_port": ResourceInterfaceBridgePort(),
"routeros_interface_bridge_vlan": ResourceInterfaceBridgeVlan(),
"routeros_interface_bridge_settings": ResourceInterfaceBridgeSettings(),
"routeros_interface_dot1x_client": ResourceInterfaceDot1xClient(),
"routeros_interface_eoip": ResourceInterfaceEoip(),
"routeros_interface_ethernet_switch": ResourceInterfaceEthernetSwitch(),
"routeros_interface_gre": ResourceInterfaceGre(),
Expand Down
61 changes: 61 additions & 0 deletions routeros/resource_interface_dot1x.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package routeros

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

// https://help.mikrotik.com/docs/display/ROS/Dot1X#Dot1X-Client
func ResourceInterfaceDot1xClient() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/interface/dot1x/client"),
MetaId: PropId(Id),

"anon_identity": {
Type: schema.TypeString,
Optional: true,
Description: "Identity for outer layer EAP authentication. Used only with `eap-ttls` and `eap-peap` methods. If not set, the value from the identity parameter will be used for outer layer EAP authentication.",
},
"certificate": {
Type: schema.TypeString,
Optional: true,
Default: "none",
Description: "Name of a certificate. Required when the `eap-tls` method is used.",
},
KeyComment: PropCommentRw,
KeyDisabled: PropDisabledRw,
"eap_methods": {
Type: schema.TypeString,
Required: true,
Description: "A list of EAP methods used for authentication: `eap-tls`, `eap-ttls`, `eap-peap`, `eap-mschapv2`.",
},
"identity": {
Type: schema.TypeString,
Required: true,
Description: "The supplicant identity that is used for EAP authentication.",
},
KeyInterface: PropInterfaceRw,
"password": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
Description: "Cleartext password for the supplicant.",
},
"status": {
Type: schema.TypeString,
Computed: true,
},
}

return &schema.Resource{
CreateContext: DefaultCreate(resSchema),
ReadContext: DefaultRead(resSchema),
UpdateContext: DefaultUpdate(resSchema),
DeleteContext: DefaultDelete(resSchema),

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

Schema: resSchema,
}
}

0 comments on commit db76369

Please sign in to comment.