From 0e5077d427dc144ab70f208a4794a903d5e8a5a8 Mon Sep 17 00:00:00 2001 From: Aria Date: Sun, 1 Oct 2023 23:41:37 +0100 Subject: a working version with principal creation --- path_config.go | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) (limited to 'path_config.go') diff --git a/path_config.go b/path_config.go index 8a3187e..0fcec4c 100644 --- a/path_config.go +++ b/path_config.go @@ -71,21 +71,12 @@ func configSchema() map[string]*framework.FieldSchema { Sensitive: true, }, }, - "kdc": { - Type: framework.TypeCommaStringSlice, - Description: "Available KDCs for the realm", - Required: true, - DisplayAttrs: &framework.DisplayAttributes{ - Name: "KDCs", - Sensitive: false, - }, - }, - "kpasswd_server": { - Type: framework.TypeCommaStringSlice, - Description: "KPasswd servers for the realm", + "kadmin_server": { + Type: framework.TypeString, + Description: "KAdmin server for the realm", Required: true, DisplayAttrs: &framework.DisplayAttributes{ - Name: "KPasswd Servers", + Name: "KAdmin Server", Sensitive: false, }, }, @@ -116,10 +107,9 @@ func (b *krbBackend) pathConfigRead(ctx context.Context, req *logical.Request, d return &logical.Response{ Data: map[string]interface{}{ - "realm": config.Realm, - "kdc": config.KDC, - "kpasswd_server": config.KPasswdServer, - "username": config.Username, + "realm": config.Realm, + "kadmin_server": config.KAdminServer, + "username": config.Username, }, }, nil } @@ -146,23 +136,10 @@ func (b *krbBackend) pathConfigWrite(ctx context.Context, req *logical.Request, return nil, fmt.Errorf("missing realm in configuration") } - // TODO: Also validate these aren't empty - if kdc, ok := data.GetOk("kdc"); ok { - c.KDC = kdc.([]string) + if kpasswd_server, ok := data.GetOk("kadmin_server"); ok { + c.KAdminServer = kpasswd_server.(string) } else if !ok && createOperation { - return nil, fmt.Errorf("missing KDCs in configuration") - } - if len(c.KDC) == 0 { - return nil, fmt.Errorf("no KDCs specified") - } - - if kpasswd_server, ok := data.GetOk("kpasswd_server"); ok { - c.KPasswdServer = kpasswd_server.([]string) - } else if !ok && createOperation { - return nil, fmt.Errorf("missing kpasswd servers in configuration") - } - if len(c.KPasswdServer) == 0 { - return nil, fmt.Errorf("no kpasswd servers specified") + return nil, fmt.Errorf("missing kadmin server in configuration") } if username, ok := data.GetOk("username"); ok { -- cgit v1.2.3