Skip to content

cdlan/lib-keycloak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keycloak

Wrapper around github.com/Nerzal/gocloak KeyCloak Go Library

Install

go get github.com/cdlan/lib-keycloak

Usage

import keycloak "github.com/cdlan/lib-keycloak"

// initialize object
kc := keycloak.Config{
    Url:        "https://kc.domain.example/auth/",
    ClientID:   "my_client_id",
    Secret:     "my_secret",
    Realm:      "my_realm",
}

ctx := context.Background()

// search user by email
user, err := kc.SearchUser(ctx, "[email protected]")
if err != nil {
    panic(err)
}

Configuration

The module has built-in support for github.com/spf13/viper.

There is also the possibility to load configurations from ENV VARS using

import keycloak "github.com/cdlan/lib-keycloak"

// create default object
kc := keycloak.Default()

// load from ENV VARS
kc.LoadVarsFromEnv()

ENV VARS

  • KC_URL: url of KC in the https://kc.domain.example/auth/ form.
  • KC_CLIENT_ID
  • KC_CLIENT_SECRET
  • KC_REALM
  • KC_SETUP_ACTIONS: comma separated actions to execute when new user is created. see here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages