Browse Source
[EDL-47] Add calls to get identity providers and client mappers
master
pablo-lo
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
59 additions and
3 deletions
-
Gopkg.lock
-
clients.go
-
definitions.go
-
identity_providers.go
|
|
|
@ -13,6 +13,14 @@ |
|
|
|
revision = "5fe45695250a8712a92d0e089add532fa06fd24d" |
|
|
|
version = "v2.1.0" |
|
|
|
|
|
|
|
[[projects]] |
|
|
|
digest = "1:1e20175fe67c4034deb8cf6103745da8493ed532ec2a1c3d073531dfbace9040" |
|
|
|
name = "github.com/cloudtrust/keycloak-client" |
|
|
|
packages = ["."] |
|
|
|
pruneopts = "" |
|
|
|
revision = "8ff2bc5438f41a4d165677d6cb38168be8bb80bc" |
|
|
|
version = "v1.3.0" |
|
|
|
|
|
|
|
[[projects]] |
|
|
|
digest = "1:bb7f91ab4d1c44a3bb2651c613463c134165bda0282fca891a63b88d1b501997" |
|
|
|
name = "github.com/coreos/go-oidc" |
|
|
|
@ -244,6 +252,7 @@ |
|
|
|
"github.com/cloudtrust/common-service", |
|
|
|
"github.com/cloudtrust/common-service/errors", |
|
|
|
"github.com/cloudtrust/common-service/log", |
|
|
|
"github.com/cloudtrust/keycloak-client", |
|
|
|
"github.com/coreos/go-oidc", |
|
|
|
"github.com/gbrlsnchs/jwt", |
|
|
|
"github.com/go-kit/kit/transport/http", |
|
|
|
|
|
|
|
@ -7,9 +7,10 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
clientsPath = "/auth/admin/realms/:realm/clients" |
|
|
|
clientIDPath = clientsPath + "/:id" |
|
|
|
clientSecret = clientsPath + "/client-secret" |
|
|
|
clientsPath = "/auth/admin/realms/:realm/clients" |
|
|
|
clientIDPath = clientsPath + "/:id" |
|
|
|
clientSecret = clientsPath + "/client-secret" |
|
|
|
clientMappersPath = clientIDPath + "/evaluate-scopes/protocol-mappers" |
|
|
|
) |
|
|
|
|
|
|
|
// GetClients returns a list of clients belonging to the realm.
|
|
|
|
@ -33,6 +34,12 @@ func (c *Client) GetClient(accessToken string, realmName, idClient string) (Clie |
|
|
|
return resp, err |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) GetClientMappers(accessToke string, realmName, idClient string) ([]ClientMapperRepresentation, error) { |
|
|
|
var resp = []ClientMapperRepresentation{} |
|
|
|
var err = c.get(accessToke, &resp, url.Path(clientMappersPath), url.Param("realm", realmName), url.Param("id", idClient)) |
|
|
|
return resp, err |
|
|
|
} |
|
|
|
|
|
|
|
// GetSecret get the client secret. idClient is the id of client (not client-id).
|
|
|
|
func (c *Client) GetSecret(accessToken string, realmName, idClient string) (CredentialRepresentation, error) { |
|
|
|
var resp = CredentialRepresentation{} |
|
|
|
|
|
|
|
@ -111,6 +111,17 @@ type ClientInitialAccessPresentation struct { |
|
|
|
Token *string `json:"token,omitempty"` |
|
|
|
} |
|
|
|
|
|
|
|
// ClientMapperRepresentation struct
|
|
|
|
// https://www.keycloak.org/docs-api/9.0/rest-api/index.html#_clientscopeevaluateresource-protocolmapperevaluationrepresentation
|
|
|
|
type ClientMapperRepresentation struct { |
|
|
|
ContainerId *string `json:"containerId,omitempty"` |
|
|
|
ContainerName *string `json:"containerName,omitempty"` |
|
|
|
ContainerType *string `json:"containerType,omitempty"` |
|
|
|
MapperId *string `json:"mapperId,omitempty"` |
|
|
|
MapperName *string `json:"mapperName,omitempty"` |
|
|
|
ProtocolMapper *string `json:"protocolMapper,omitempty"` |
|
|
|
} |
|
|
|
|
|
|
|
// ClientMappingsRepresentation struct
|
|
|
|
type ClientMappingsRepresentation struct { |
|
|
|
Client *string `json:"client,omitempty"` |
|
|
|
|
|
|
|
@ -0,0 +1,29 @@ |
|
|
|
package keycloak |
|
|
|
|
|
|
|
import ( |
|
|
|
"gopkg.in/h2non/gentleman.v2/plugins/url" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
idpsPath = "/auth/admin/realms/:realm/identity-provider/instances" |
|
|
|
idpAliasPath = idpsPath + "/:alias" |
|
|
|
idpMappersPath = idpAliasPath + "/mappers" |
|
|
|
) |
|
|
|
|
|
|
|
func (c *Client) GetIdps(accessToken string, realmName string) ([]IdentityProviderRepresentation, error) { |
|
|
|
var resp = []IdentityProviderRepresentation{} |
|
|
|
var err = c.get(accessToken, &resp, url.Path(idpsPath), url.Param("realm", realmName)) |
|
|
|
return resp, err |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) GetIdp(accessToken string, realmName string, idpAlias string) (IdentityProviderRepresentation, error) { |
|
|
|
var resp = IdentityProviderRepresentation{} |
|
|
|
var err = c.get(accessToken, &resp, url.Path(idpAliasPath), url.Param("realm", realmName), url.Param("alias", idpAlias)) |
|
|
|
return resp, err |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) GetIdpMappers(accessToken string, realmName string, idpAlias string) ([]IdentityProviderMapperRepresentation, error) { |
|
|
|
var resp = []IdentityProviderMapperRepresentation{} |
|
|
|
var err = c.get(accessToken, &resp, url.Path(idpMappersPath), url.Param("realm", realmName), url.Param("alias", idpAlias)) |
|
|
|
return resp, err |
|
|
|
} |