From 05b77544d7981f73d9a1477d6869ed058554c523 Mon Sep 17 00:00:00 2001 From: Johan Droz Date: Thu, 15 Mar 2018 18:48:56 +0100 Subject: [PATCH] Add some routes --- authentication_management.go | 44 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/authentication_management.go b/authentication_management.go index 453bd41..13b9444 100644 --- a/authentication_management.go +++ b/authentication_management.go @@ -1,16 +1,38 @@ package keycloak -// Get authenticator providers Returns a list of authenticator providers. -// GET /{realm}/authentication/authenticator-providers - -// Get client authenticator providers Returns a list of client authenticator providers. -// GET /{realm}/authentication/client-authenticator-providers - -// Get authenticator provider’s configuration description -// GET /{realm}/authentication/config-description/{providerId} - -// Get authenticator configuration -// GET /{realm}/authentication/config/{id} +import "gopkg.in/h2non/gentleman.v2/plugins/url" + +const ( + authenticationManagementPath = "/auth/admin/realms/:realm/authentication" +) + +// GetAuthenticatorProviders returns a list of authenticator providers. +func (c *Client) GetAuthenticatorProviders(realmName string) ([]map[string]interface{}, error) { + var resp = []map[string]interface{}{} + var err = c.get(&resp, url.Path(authenticationManagementPath+"/authenticator-providers"), url.Param("realm", realmName)) + return resp, err +} + +// GetClientAuthenticatorProviders returns a list of client authenticator providers. +func (c *Client) GetClientAuthenticatorProviders(realmName string) ([]map[string]interface{}, error) { + var resp = []map[string]interface{}{} + var err = c.get(&resp, url.Path(authenticationManagementPath+"client-authenticator-providers"), url.Param("realm", realmName)) + return resp, err +} + +// GetAuthenticatorProviderConfig returns the authenticator provider’s configuration description. +func (c *Client) GetAuthenticatorProviderConfig(realmName, providerID string) (AuthenticatorConfigInfoRepresentation, error) { + var resp = AuthenticatorConfigInfoRepresentation{} + var err = c.get(&resp, url.Path(authenticationManagementPath+"config-description/:providerID"), url.Param("realm", realmName), url.Param("providerID", providerID)) + return resp, err +} + +// GetAuthenticatorConfig returns the authenticator configuration. +func (c *Client) GetAuthenticatorConfig(realmName, configID string) (AuthenticatorConfigRepresentation, error) { + var resp = AuthenticatorConfigRepresentation{} + var err = c.get(&resp, url.Path(authenticationManagementPath+"config/:id"), url.Param("realm", realmName), url.Param("id", configID)) + return resp, err +} // Update authenticator configuration // PUT /{realm}/authentication/config/{id}