You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Nicolas Massé 4a7df5ace9 update dependencies 4 years ago
integration flatten the packages 5 years ago
.gitignore remove unneeded features 5 years ago
LICENSE Initial commit 8 years ago
README.md doc 5 years ago
attack_detection.go flatten the packages 5 years ago
authentication_management.go flatten the packages 5 years ago
client_attribute_certificate.go flatten the packages 5 years ago
client_initial_access.go flatten the packages 5 years ago
client_registration_policy.go flatten the packages 5 years ago
client_role_mappings.go flatten the packages 5 years ago
clients.go flatten the packages 5 years ago
components.go flatten the packages 5 years ago
config.go Fix lint issues 6 years ago
credentials.go flatten the packages 5 years ago
definitions.go flatten the packages 5 years ago
errormessages.go cleanup and prepare to fork 5 years ago
go.mod update dependencies 4 years ago
go.sum update dependencies 4 years ago
groups.go flatten the packages 5 years ago
identity_providers.go flatten the packages 5 years ago
keycloak_client.go flatten the packages 5 years ago
model_toolbox.go Sonar code smells and Unauthorized processing 6 years ago
model_toolbox_test.go Sonar code smells and Unauthorized processing 6 years ago
realm.go flatten the packages 5 years ago
recovery_code.go flatten the packages 5 years ago
roles.go flatten the packages 5 years ago
users.go flatten the packages 5 years ago

README.md

Golang Keycloak REST Client

This Golang library provides Types and Methods to drive a Keycloak instance through its REST Admin interface.

Supported Features

  • Realms: CRUD, Export, Import
  • Clients: CRU
  • Users: CRUD
  • Components: CRUD

Hello, World example

package main

import (
	"fmt"
	"log"
	"time"

	keycloak "github.com/nmasse-itix/keycloak-client"
)

func main() {
	config := keycloak.Config{
		AddrTokenProvider: "http://localhost:8080/auth/realm/master",
		AddrAPI:           "http://localhost:8080/auth",
		Timeout:           10 * time.Second,
	}

	client, err := keycloak.NewClient(config)
	if err != nil {
		log.Fatalf("could not create keycloak client: %v", err)
	}

	accessToken, err := client.GetToken("master", "admin", "admin")
	if err != nil {
		log.Fatalf("could not get access token: %v", err)
	}

	realms, err := client.GetRealms(accessToken)
	if err != nil {
		log.Fatalf("could not get realms: %v", err)
	}

	for _, realm := range realms {
		fmt.Println(*realm.Realm)
	}
}