Browse Source

Moves keycloak client from the keycloak-bridge repository

master
CMajeri 8 years ago
committed by Majeri Kasmaei Chervine
parent
commit
7c61ba358d
  1. 51
      Gopkg.lock
  2. 34
      Gopkg.toml
  3. 4
      README.md
  4. 81
      client/client_test.go
  5. 143
      client/common.go
  6. 660
      client/definitions.go
  7. 29
      client/realms.go
  8. 29
      client/users.go
  9. 4
      utils/.idea/misc.xml
  10. 8
      utils/.idea/modules.xml
  11. 11
      utils/.idea/utils.iml
  12. 313
      utils/.idea/workspace.xml
  13. 78
      utils/bin/activate
  14. 36
      utils/bin/activate.csh
  15. 76
      utils/bin/activate.fish
  16. 34
      utils/bin/activate_this.py
  17. 11
      utils/bin/chardetect
  18. 11
      utils/bin/easy_install
  19. 11
      utils/bin/easy_install-3.5
  20. 11
      utils/bin/pip
  21. 11
      utils/bin/pip3
  22. 11
      utils/bin/pip3.5
  23. 1
      utils/bin/python
  24. 78
      utils/bin/python-config
  25. BIN
      utils/bin/python3
  26. 1
      utils/bin/python3.5
  27. 11
      utils/bin/wheel
  28. 91
      utils/file_parser.py
  29. 38
      utils/html_parser.py
  30. 1
      utils/include/python3.5m
  31. 1
      utils/lib/python3.5/__future__.py
  32. BIN
      utils/lib/python3.5/__pycache__/__future__.cpython-35.pyc
  33. BIN
      utils/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc
  34. BIN
      utils/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc
  35. BIN
      utils/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc
  36. BIN
      utils/lib/python3.5/__pycache__/abc.cpython-35.pyc
  37. BIN
      utils/lib/python3.5/__pycache__/base64.cpython-35.pyc
  38. BIN
      utils/lib/python3.5/__pycache__/bisect.cpython-35.pyc
  39. BIN
      utils/lib/python3.5/__pycache__/codecs.cpython-35.pyc
  40. BIN
      utils/lib/python3.5/__pycache__/copy.cpython-35.pyc
  41. BIN
      utils/lib/python3.5/__pycache__/copyreg.cpython-35.pyc
  42. BIN
      utils/lib/python3.5/__pycache__/fnmatch.cpython-35.pyc
  43. BIN
      utils/lib/python3.5/__pycache__/functools.cpython-35.pyc
  44. BIN
      utils/lib/python3.5/__pycache__/genericpath.cpython-35.pyc
  45. BIN
      utils/lib/python3.5/__pycache__/hashlib.cpython-35.pyc
  46. BIN
      utils/lib/python3.5/__pycache__/heapq.cpython-35.pyc
  47. BIN
      utils/lib/python3.5/__pycache__/hmac.cpython-35.pyc
  48. BIN
      utils/lib/python3.5/__pycache__/imp.cpython-35.pyc
  49. BIN
      utils/lib/python3.5/__pycache__/io.cpython-35.pyc
  50. BIN
      utils/lib/python3.5/__pycache__/keyword.cpython-35.pyc
  51. BIN
      utils/lib/python3.5/__pycache__/linecache.cpython-35.pyc
  52. BIN
      utils/lib/python3.5/__pycache__/locale.cpython-35.pyc
  53. BIN
      utils/lib/python3.5/__pycache__/operator.cpython-35.pyc
  54. BIN
      utils/lib/python3.5/__pycache__/os.cpython-35.pyc
  55. BIN
      utils/lib/python3.5/__pycache__/posixpath.cpython-35.pyc
  56. BIN
      utils/lib/python3.5/__pycache__/random.cpython-35.pyc
  57. BIN
      utils/lib/python3.5/__pycache__/re.cpython-35.pyc
  58. BIN
      utils/lib/python3.5/__pycache__/reprlib.cpython-35.pyc
  59. BIN
      utils/lib/python3.5/__pycache__/shutil.cpython-35.pyc
  60. BIN
      utils/lib/python3.5/__pycache__/site.cpython-35.pyc
  61. BIN
      utils/lib/python3.5/__pycache__/sre_compile.cpython-35.pyc
  62. BIN
      utils/lib/python3.5/__pycache__/sre_constants.cpython-35.pyc
  63. BIN
      utils/lib/python3.5/__pycache__/sre_parse.cpython-35.pyc
  64. BIN
      utils/lib/python3.5/__pycache__/stat.cpython-35.pyc
  65. BIN
      utils/lib/python3.5/__pycache__/struct.cpython-35.pyc
  66. BIN
      utils/lib/python3.5/__pycache__/tarfile.cpython-35.pyc
  67. BIN
      utils/lib/python3.5/__pycache__/tempfile.cpython-35.pyc
  68. BIN
      utils/lib/python3.5/__pycache__/token.cpython-35.pyc
  69. BIN
      utils/lib/python3.5/__pycache__/tokenize.cpython-35.pyc
  70. BIN
      utils/lib/python3.5/__pycache__/types.cpython-35.pyc
  71. BIN
      utils/lib/python3.5/__pycache__/warnings.cpython-35.pyc
  72. BIN
      utils/lib/python3.5/__pycache__/weakref.cpython-35.pyc
  73. 1
      utils/lib/python3.5/_bootlocale.py
  74. 1
      utils/lib/python3.5/_collections_abc.py
  75. 1
      utils/lib/python3.5/_dummy_thread.py
  76. 1
      utils/lib/python3.5/_weakrefset.py
  77. 1
      utils/lib/python3.5/abc.py
  78. 1
      utils/lib/python3.5/base64.py
  79. 1
      utils/lib/python3.5/bisect.py
  80. 1
      utils/lib/python3.5/codecs.py
  81. 1
      utils/lib/python3.5/collections
  82. 1
      utils/lib/python3.5/config-3.5m
  83. 1
      utils/lib/python3.5/copy.py
  84. 1
      utils/lib/python3.5/copyreg.py
  85. 101
      utils/lib/python3.5/distutils/__init__.py
  86. BIN
      utils/lib/python3.5/distutils/__pycache__/__init__.cpython-35.pyc
  87. 6
      utils/lib/python3.5/distutils/distutils.cfg
  88. 1
      utils/lib/python3.5/encodings
  89. 1
      utils/lib/python3.5/fnmatch.py
  90. 1
      utils/lib/python3.5/functools.py
  91. 1
      utils/lib/python3.5/genericpath.py
  92. 1
      utils/lib/python3.5/hashlib.py
  93. 1
      utils/lib/python3.5/heapq.py
  94. 1
      utils/lib/python3.5/hmac.py
  95. 1
      utils/lib/python3.5/imp.py
  96. 1
      utils/lib/python3.5/importlib
  97. 1
      utils/lib/python3.5/io.py
  98. 1
      utils/lib/python3.5/keyword.py
  99. 1
      utils/lib/python3.5/lib-dynload
  100. 1
      utils/lib/python3.5/linecache.py

51
Gopkg.lock

@ -0,0 +1,51 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
version = "v1.1.0"
[[projects]]
name = "github.com/pkg/errors"
packages = ["."]
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
name = "github.com/stretchr/testify"
packages = ["assert","require"]
revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0"
version = "v1.1.4"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = ["idna","publicsuffix"]
revision = "66aacef3dd8a676686c7ae3716979581e8b03c47"
[[projects]]
branch = "master"
name = "golang.org/x/text"
packages = ["internal/gen","internal/triegen","internal/ucd","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"]
revision = "bd91bbf73e9a4a801adbfb97133c992678533126"
[[projects]]
name = "gopkg.in/h2non/gentleman.v2"
packages = [".","context","middleware","mux","plugin","plugins/body","plugins/bodytype","plugins/cookies","plugins/headers","plugins/multipart","plugins/query","plugins/timeout","plugins/url","utils"]
revision = "306092e612855f1ce485d8bd35361a0d10fac40f"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "a3cc4fb82e0ff60bd971bed49992ef0a7aba2bfe6896479cd1b551afbcc17282"
solver-name = "gps-cdcl"
solver-version = 1

34
Gopkg.toml

@ -0,0 +1,34 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"
[[constraint]]
name = "github.com/stretchr/testify"
version = "1.1.4"
[[constraint]]
name = "gopkg.in/h2non/gentleman.v2"
version = "2.0.0"

4
README.md

@ -1 +1,3 @@
# keycloak-client ## Basic keycloak client in go
This repo provides a basic keycloak client in go, and utilities to parse the html docs into usable schema files because I wasn't good enough to make maven give me ascii documentation. I should try again at some point. It uses swagger, so it SHOULD be doable, it was just easier at that time to write an html parser to quickly prototype something.

81
client/client_test.go

@ -0,0 +1,81 @@
package client
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"fmt"
"crypto/cipher"
"crypto/aes"
)
type setivable interface {
cipher.BlockMode
SetIV([]byte)
}
func Test_Poop(t *testing.T) {
var k []byte = make([]byte, 16)
var iv []byte = k
b, e := aes.NewCipher(k)
if e != nil {
fmt.Println(e)
return
}
var c = cipher.NewCBCEncrypter(b, iv)
switch cp := c.(type) {
case setivable:
fmt.Println("Haha!")
cp.SetIV(k)
case cipher.BlockMode:
fmt.Println("Hoho!")
}
}
func initTest(t *testing.T) Client {
var config HttpConfig = HttpConfig{
Addr: "http://127.0.0.1:8080",
Username: "admin",
Password: "admin",
Timeout: time.Second * 5,
}
var client Client
{
var err error
client, err = NewHttpClient(config)
require.Nil(t, err, "Failed to create client")
}
return client
}
func TestClient_getToken(t *testing.T) {
var genClient Client = initTest(t)
var httpClient *client = genClient.(*client)
var err error = httpClient.getToken()
require.Nil(t, err, "Failed to get token")
fmt.Println(httpClient.accessToken)
}
func TestClient_GetRealms(t *testing.T) {
var client Client = initTest(t)
var realms []map[string]interface{}
{
var err error
realms, err = client.GetRealms()
require.Nil(t, err, "Failed to get realms")
}
fmt.Println(realms)
}
func TestClient_GetUsers(t *testing.T) {
var client Client = initTest(t)
var users []UserRepresentation
{
var err error
users, err = client.GetUsers("master")
require.Nil(t, err, "Failed to get users")
}
fmt.Println(users[0])
}

143
client/common.go

@ -0,0 +1,143 @@
package client
import (
"fmt"
"net/url"
"github.com/pkg/errors"
"time"
"net/http"
"gopkg.in/h2non/gentleman.v2"
"gopkg.in/h2non/gentleman.v2/plugins/timeout"
//"gopkg.in/h2non/gentleman.v2/plugins/multipart"
)
type Client interface {
GetRealms() ([]map[string]interface{}, error)
GetUsers(realm string) ([]UserRepresentation, error)
}
type HttpConfig struct {
Addr string
Username string
Password string
Timeout time.Duration
}
type client struct {
username string
password string
accessToken string
httpClient *gentleman.Client
}
func NewHttpClient(config HttpConfig) (Client, error) {
var u *url.URL
{
var err error
u, err = url.Parse(config.Addr)
if err != nil {
return nil, errors.Wrap(err, "Parse failed")
}
}
if u.Scheme != "http" {
var m string = fmt.Sprint("Unsupported protocol %s. Your address must start with http://", u.Scheme)
return nil, errors.New(m)
}
var httpClient *gentleman.Client = gentleman.New()
{
httpClient = httpClient.URL(u.String())
httpClient = httpClient.Use(timeout.Request(config.Timeout))
}
return &client{
username: config.Username,
password: config.Password,
httpClient: httpClient,
}, nil
}
func (c *client) getToken() error {
var req *gentleman.Request
{
var authPath string = "/auth/realms/master/protocol/openid-connect/token"
//var formData multipart.FormData = multipart.FormData{
// Data: map[string]multipart.Values{
// "username": multipart.Values{c.username},
// "password": multipart.Values{c.password},
// "grant_type": multipart.Values{"password"},
// "client_id": multipart.Values{"admin-cli"},
// },
//}
req = c.httpClient.Post()
req = req.SetHeader("Content-Type", "application/x-www-form-urlencoded")
req = req.Path(authPath)
req = req.Type("urlencoded")
req = req.BodyString(fmt.Sprintf("username=%s&password=%s&grant_type=password&client_id=admin-cli",c.username,c.password))
}
var resp *gentleman.Response
{
var err error
resp, err = req.Do()
if err != nil {
return errors.Wrap(err, "Failed to get the token response")
}
}
defer resp.Close()
var unmarshalledBody map[string]interface{}
{
var err error
err = resp.JSON(&unmarshalledBody)
if err != nil {
return errors.Wrap(err, "Failed to unmarshal response json")
}
}
var accessToken interface{}
{
var ok bool
accessToken, ok = unmarshalledBody["access_token"]
if !ok {
return errors.New("No access token in reponse body")
}
}
c.accessToken = accessToken.(string)
return nil
}
func (c *client) do(path string) (*gentleman.Response, error) {
var req *gentleman.Request = c.httpClient.Get()
{
req = req.Path(path)
req = req.SetHeader("Authorization", fmt.Sprintf("Bearer %s", c.accessToken))
}
var resp *gentleman.Response
{
var err error
resp, err = req.Do()
if err != nil {
return nil, errors.Wrap(err, "Failed to get the response")
}
switch resp.StatusCode {
case http.StatusUnauthorized:
var err = c.getToken()
//This induces a potential infinite loop, where a new token gets requested and the
//process gets delayed so much it expires before the recursion.
//It is decided that should this happen, the machine would be considered to be in terrible shape
//and the loop wouldn't be the biggest problem.
if err != nil {
return nil, errors.Wrap(err, "Failed to get token")
}
return c.do(path)
default:
return resp, nil
}
}
}

660
client/definitions.go

@ -0,0 +1,660 @@
package client
type AdminEventRepresentation struct {
AuthDetails *AuthDetailsRepresentation `json:"authDetails,omitempty"`
Error *string `json:"error,omitempty"`
OperationType *string `json:"operationType,omitempty"`
RealmId *string `json:"realmId,omitempty"`
Representation *string `json:"representation,omitempty"`
ResourcePath *string `json:"resourcePath,omitempty"`
ResourceType *string `json:"resourceType,omitempty"`
Time *int64 `json:"time,omitempty"`
}
type AuthDetailsRepresentation struct {
ClientId *string `json:"clientId,omitempty"`
IpAddress *string `json:"ipAddress,omitempty"`
RealmId *string `json:"realmId,omitempty"`
UserId *string `json:"userId,omitempty"`
}
type AuthenticationExecutionExportRepresentation struct {
Authenticator *string `json:"authenticator,omitempty"`
AuthenticatorConfig *string `json:"authenticatorConfig,omitempty"`
AuthenticatorFlow *bool `json:"authenticatorFlow,omitempty"`
AutheticatorFlow *bool `json:"autheticatorFlow,omitempty"`
FlowAlias *string `json:"flowAlias,omitempty"`
Priority *int32 `json:"priority,omitempty"`
Requirement *string `json:"requirement,omitempty"`
UserSetupAllowed *bool `json:"userSetupAllowed,omitempty"`
}
type AuthenticationExecutionInfoRepresentation struct {
Alias *string `json:"alias,omitempty"`
AuthenticationConfig *string `json:"authenticationConfig,omitempty"`
AuthenticationFlow *bool `json:"authenticationFlow,omitempty"`
Configurable *bool `json:"configurable,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
FlowId *string `json:"flowId,omitempty"`
Id *string `json:"id,omitempty"`
Index *int32 `json:"index,omitempty"`
Level *int32 `json:"level,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
Requirement *string `json:"requirement,omitempty"`
RequirementChoices *[]string `json:"requirementChoices,omitempty"`
}
type AuthenticationExecutionRepresentation struct {
Authenticator *string `json:"authenticator,omitempty"`
AuthenticatorConfig *string `json:"authenticatorConfig,omitempty"`
AuthenticatorFlow *bool `json:"authenticatorFlow,omitempty"`
AutheticatorFlow *bool `json:"autheticatorFlow,omitempty"`
FlowId *string `json:"flowId,omitempty"`
Id *string `json:"id,omitempty"`
ParentFlow *string `json:"parentFlow,omitempty"`
Priority *int32 `json:"priority,omitempty"`
Requirement *string `json:"requirement,omitempty"`
}
type AuthenticationFlowRepresentation struct {
Alias *string `json:"alias,omitempty"`
AuthenticationExecutions *AuthenticationExecutionExportRepresentation `json:"authenticationExecutions,omitempty"`
BuiltIn *bool `json:"builtIn,omitempty"`
Description *string `json:"description,omitempty"`
Id *string `json:"id,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
TopLevel *bool `json:"topLevel,omitempty"`
}
type AuthenticatorConfigInfoRepresentation struct {
HelpText *string `json:"helpText,omitempty"`
Name *string `json:"name,omitempty"`
Properties *ConfigPropertyRepresentation `json:"properties,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
}
type AuthenticatorConfigRepresentation struct {
Alias *string `json:"alias,omitempty"`
Config *map[string]interface{} `json:"config,omitempty"`
Id *string `json:"id,omitempty"`
}
type CertificateRepresentation struct {
Certificate *string `json:"certificate,omitempty"`
Kid *string `json:"kid,omitempty"`
PrivateKey *string `json:"privateKey,omitempty"`
PublicKey *string `json:"publicKey,omitempty"`
}
type ClientInitialAccessCreatePresentation struct {
Count *int32 `json:"count,omitempty"`
Expiration *int32 `json:"expiration,omitempty"`
}
type ClientInitialAccessPresentation struct {
Count *int32 `json:"count,omitempty"`
Expiration *int32 `json:"expiration,omitempty"`
Id *string `json:"id,omitempty"`
RemainingCount *int32 `json:"remainingCount,omitempty"`
Timestamp *int32 `json:"timestamp,omitempty"`
Token *string `json:"token,omitempty"`
}
type ClientMappingsRepresentation struct {
Client *string `json:"client,omitempty"`
Id *string `json:"id,omitempty"`
Mappings *RoleRepresentation `json:"mappings,omitempty"`
}
type ClientRepresentation struct {
Access *map[string]interface{} `json:"access,omitempty"`
AdminUrl *string `json:"adminUrl,omitempty"`
Attributes *map[string]interface{} `json:"attributes,omitempty"`
AuthorizationServicesEnabled *bool `json:"authorizationServicesEnabled,omitempty"`
AuthorizationSettings *ResourceServerRepresentation `json:"authorizationSettings,omitempty"`
BaseUrl *string `json:"baseUrl,omitempty"`
BearerOnly *bool `json:"bearerOnly,omitempty"`
ClientAuthenticatorType *string `json:"clientAuthenticatorType,omitempty"`
ClientId *string `json:"clientId,omitempty"`
ClientTemplate *string `json:"clientTemplate,omitempty"`
ConsentRequired *bool `json:"consentRequired,omitempty"`
DefaultRoles *[]string `json:"defaultRoles,omitempty"`
Description *string `json:"description,omitempty"`
DirectAccessGrantsEnabled *bool `json:"directAccessGrantsEnabled,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
FrontchannelLogout *bool `json:"frontchannelLogout,omitempty"`
FullScopeAllowed *bool `json:"fullScopeAllowed,omitempty"`
Id *string `json:"id,omitempty"`
ImplicitFlowEnabled *bool `json:"implicitFlowEnabled,omitempty"`
Name *string `json:"name,omitempty"`
NodeReRegistrationTimeout *int32 `json:"nodeReRegistrationTimeout,omitempty"`
NotBefore *int32 `json:"notBefore,omitempty"`
Protocol *string `json:"protocol,omitempty"`
ProtocolMappers *ProtocolMapperRepresentation `json:"protocolMappers,omitempty"`
PublicClient *bool `json:"publicClient,omitempty"`
RedirectUris *[]string `json:"redirectUris,omitempty"`
RegisteredNodes *map[string]interface{} `json:"registeredNodes,omitempty"`
RegistrationAccessToken *string `json:"registrationAccessToken,omitempty"`
RootUrl *string `json:"rootUrl,omitempty"`
Secret *string `json:"secret,omitempty"`
ServiceAccountsEnabled *bool `json:"serviceAccountsEnabled,omitempty"`
StandardFlowEnabled *bool `json:"standardFlowEnabled,omitempty"`
SurrogateAuthRequired *bool `json:"surrogateAuthRequired,omitempty"`
UseTemplateConfig *bool `json:"useTemplateConfig,omitempty"`
UseTemplateMappers *bool `json:"useTemplateMappers,omitempty"`
UseTemplateScope *bool `json:"useTemplateScope,omitempty"`
WebOrigins *[]string `json:"webOrigins,omitempty"`
}
type ClientTemplateRepresentation struct {
Attributes *map[string]interface{} `json:"attributes,omitempty"`
BearerOnly *bool `json:"bearerOnly,omitempty"`
ConsentRequired *bool `json:"consentRequired,omitempty"`
Description *string `json:"description,omitempty"`
DirectAccessGrantsEnabled *bool `json:"directAccessGrantsEnabled,omitempty"`
FrontchannelLogout *bool `json:"frontchannelLogout,omitempty"`
FullScopeAllowed *bool `json:"fullScopeAllowed,omitempty"`
Id *string `json:"id,omitempty"`
ImplicitFlowEnabled *bool `json:"implicitFlowEnabled,omitempty"`
Name *string `json:"name,omitempty"`
Protocol *string `json:"protocol,omitempty"`
ProtocolMappers *ProtocolMapperRepresentation `json:"protocolMappers,omitempty"`
PublicClient *bool `json:"publicClient,omitempty"`
ServiceAccountsEnabled *bool `json:"serviceAccountsEnabled,omitempty"`
StandardFlowEnabled *bool `json:"standardFlowEnabled,omitempty"`
}
type ComponentExportRepresentation struct {
Config *MultivaluedHashMap `json:"config,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
SubComponents *MultivaluedHashMap `json:"subComponents,omitempty"`
SubType *string `json:"subType,omitempty"`
}
type ComponentRepresentation struct {
Config *MultivaluedHashMap `json:"config,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
ParentId *string `json:"parentId,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
ProviderType *string `json:"providerType,omitempty"`
SubType *string `json:"subType,omitempty"`
}
type ComponentTypeRepresentation struct {
HelpText *string `json:"helpText,omitempty"`
Id *string `json:"id,omitempty"`
Metadata *map[string]interface{} `json:"metadata,omitempty"`
Properties *ConfigPropertyRepresentation `json:"properties,omitempty"`
}
type ConfigPropertyRepresentation struct {
DefaultValue *map[string]interface{} `json:"defaultValue,omitempty"`
HelpText *string `json:"helpText,omitempty"`
Label *string `json:"label,omitempty"`
Name *string `json:"name,omitempty"`
Options *[]string `json:"options,omitempty"`
Secret *bool `json:"secret,omitempty"`
Type *string `json:"type,omitempty"`
}
type CredentialRepresentation struct {
Algorithm *string `json:"algorithm,omitempty"`
Config *MultivaluedHashMap `json:"config,omitempty"`
Counter *int32 `json:"counter,omitempty"`
CreatedDate *int64 `json:"createdDate,omitempty"`
Device *string `json:"device,omitempty"`
Digits *int32 `json:"digits,omitempty"`
HashIterations *int32 `json:"hashIterations,omitempty"`
HashedSaltedValue *string `json:"hashedSaltedValue,omitempty"`
Period *int32 `json:"period,omitempty"`
Salt *string `json:"salt,omitempty"`
Temporary *bool `json:"temporary,omitempty"`
Type *string `json:"type,omitempty"`
Value *string `json:"value,omitempty"`
}
type EventRepresentation struct {
ClientId *string `json:"clientId,omitempty"`
Details *map[string]interface{} `json:"details,omitempty"`
Error *string `json:"error,omitempty"`
IpAddress *string `json:"ipAddress,omitempty"`
RealmId *string `json:"realmId,omitempty"`
SessionId *string `json:"sessionId,omitempty"`
Time *int64 `json:"time,omitempty"`
Type *string `json:"type,omitempty"`
UserId *string `json:"userId,omitempty"`
}
type FederatedIdentityRepresentation struct {
IdentityProvider *string `json:"identityProvider,omitempty"`
UserId *string `json:"userId,omitempty"`
UserName *string `json:"userName,omitempty"`
}
type GlobalRequestResult struct {
FailedRequests *[]string `json:"failedRequests,omitempty"`
SuccessRequests *[]string `json:"successRequests,omitempty"`
}
type GroupRepresentation struct {
Access *map[string]interface{} `json:"access,omitempty"`
Attributes *map[string]interface{} `json:"attributes,omitempty"`
ClientRoles *map[string]interface{} `json:"clientRoles,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Path *string `json:"path,omitempty"`
RealmRoles *[]string `json:"realmRoles,omitempty"`
SubGroups *GroupRepresentation `json:"subGroups,omitempty"`
}
type IdentityProviderMapperRepresentation struct {
Config *map[string]interface{} `json:"config,omitempty"`
Id *string `json:"id,omitempty"`
IdentityProviderAlias *string `json:"identityProviderAlias,omitempty"`
IdentityProviderMapper *string `json:"identityProviderMapper,omitempty"`
Name *string `json:"name,omitempty"`
}
type IdentityProviderRepresentation struct {
AddReadTokenRoleOnCreate *bool `json:"addReadTokenRoleOnCreate,omitempty"`
Alias *string `json:"alias,omitempty"`
Config *map[string]interface{} `json:"config,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
FirstBrokerLoginFlowAlias *string `json:"firstBrokerLoginFlowAlias,omitempty"`
InternalId *string `json:"internalId,omitempty"`
LinkOnly *bool `json:"linkOnly,omitempty"`
PostBrokerLoginFlowAlias *string `json:"postBrokerLoginFlowAlias,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
StoreToken *bool `json:"storeToken,omitempty"`
TrustEmail *bool `json:"trustEmail,omitempty"`
}
type KeysMetadataRepresentation struct {
Active *map[string]interface{} `json:"active,omitempty"`
Keys *KeysMetadataRepresentation_KeyMetadataRepresentation `json:"keys,omitempty"`
}
type KeysMetadataRepresentation_KeyMetadataRepresentation struct {
Certificate *string `json:"certificate,omitempty"`
Kid *string `json:"kid,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
ProviderPriority *int64 `json:"providerPriority,omitempty"`
PublicKey *string `json:"publicKey,omitempty"`
Status *string `json:"status,omitempty"`
Type *string `json:"type,omitempty"`
}
type KeyStoreConfig struct {
Format *string `json:"format,omitempty"`
KeyAlias *string `json:"keyAlias,omitempty"`
KeyPassword *string `json:"keyPassword,omitempty"`
RealmAlias *string `json:"realmAlias,omitempty"`
RealmCertificate *bool `json:"realmCertificate,omitempty"`
StorePassword *string `json:"storePassword,omitempty"`
}
type ManagementPermissionReference struct {
Enabled *bool `json:"enabled,omitempty"`
Resource *string `json:"resource,omitempty"`
ScopePermissions *map[string]interface{} `json:"scopePermissions,omitempty"`
}
type MappingsRepresentation struct {
ClientMappings *map[string]interface{} `json:"clientMappings,omitempty"`
RealmMappings *RoleRepresentation `json:"realmMappings,omitempty"`
}
type MemoryInfoRepresentation struct {
Free *int64 `json:"free,omitempty"`
FreeFormated *string `json:"freeFormated,omitempty"`
FreePercentage *int64 `json:"freePercentage,omitempty"`
Total *int64 `json:"total,omitempty"`
TotalFormated *string `json:"totalFormated,omitempty"`
Used *int64 `json:"used,omitempty"`
UsedFormated *string `json:"usedFormated,omitempty"`
}
type MultivaluedHashMap struct {
Empty *bool `json:"empty,omitempty"`
LoadFactor *int32 `json:"loadFactor,omitempty"`
Threshold *int32 `json:"threshold,omitempty"`
}
type PartialImportRepresentation struct {
Clients *ClientRepresentation `json:"clients,omitempty"`
Groups *GroupRepresentation `json:"groups,omitempty"`
IdentityProviders *IdentityProviderRepresentation `json:"identityProviders,omitempty"`
IfResourceExists *string `json:"ifResourceExists,omitempty"`
Policy *string `json:"policy,omitempty"`
Roles *RolesRepresentation `json:"roles,omitempty"`
Users *UserRepresentation `json:"users,omitempty"`
}
type PasswordPolicyTypeRepresentation struct {
ConfigType *string `json:"configType,omitempty"`
DefaultValue *string `json:"defaultValue,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
Id *string `json:"id,omitempty"`
MultipleSupported *bool `json:"multipleSupported,omitempty"`
}
type PolicyRepresentation struct {
Config *map[string]interface{} `json:"config,omitempty"`
DecisionStrategy *string `json:"decisionStrategy,omitempty"`
Description *string `json:"description,omitempty"`
Id *string `json:"id,omitempty"`
Logic *string `json:"logic,omitempty"`
Name *string `json:"name,omitempty"`
Policies *[]string `json:"policies,omitempty"`
Resources *[]string `json:"resources,omitempty"`
Scopes *[]string `json:"scopes,omitempty"`
Type *string `json:"type,omitempty"`
}
type ProfileInfoRepresentation struct {
DisabledFeatures *[]string `json:"disabledFeatures,omitempty"`
Name *string `json:"name,omitempty"`
}
type ProtocolMapperRepresentation struct {
Config *map[string]interface{} `json:"config,omitempty"`
ConsentRequired *bool `json:"consentRequired,omitempty"`
ConsentText *string `json:"consentText,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Protocol *string `json:"protocol,omitempty"`
ProtocolMapper *string `json:"protocolMapper,omitempty"`
}
type ProviderRepresentation struct {
OperationalInfo *map[string]interface{} `json:"operationalInfo,omitempty"`
Order *int32 `json:"order,omitempty"`
}
type RealmEventsConfigRepresentation struct {
AdminEventsDetailsEnabled *bool `json:"adminEventsDetailsEnabled,omitempty"`
AdminEventsEnabled *bool `json:"adminEventsEnabled,omitempty"`
EnabledEventTypes *[]string `json:"enabledEventTypes,omitempty"`
EventsEnabled *bool `json:"eventsEnabled,omitempty"`
EventsExpiration *int64 `json:"eventsExpiration,omitempty"`
EventsListeners *[]string `json:"eventsListeners,omitempty"`
}
type RealmRepresentation struct {
AccessCodeLifespan *int32 `json:"accessCodeLifespan,omitempty"`
AccessCodeLifespanLogin *int32 `json:"accessCodeLifespanLogin,omitempty"`
AccessCodeLifespanUserAction *int32 `json:"accessCodeLifespanUserAction,omitempty"`
AccessTokenLifespan *int32 `json:"accessTokenLifespan,omitempty"`
AccessTokenLifespanForImplicitFlow *int32 `json:"accessTokenLifespanForImplicitFlow,omitempty"`
AccountTheme *string `json:"accountTheme,omitempty"`
ActionTokenGeneratedByAdminLifespan *int32 `json:"actionTokenGeneratedByAdminLifespan,omitempty"`
ActionTokenGeneratedByUserLifespan *int32 `json:"actionTokenGeneratedByUserLifespan,omitempty"`
AdminEventsDetailsEnabled *bool `json:"adminEventsDetailsEnabled,omitempty"`
AdminEventsEnabled *bool `json:"adminEventsEnabled,omitempty"`
AdminTheme *string `json:"adminTheme,omitempty"`
Attributes *map[string]interface{} `json:"attributes,omitempty"`
AuthenticationFlows *AuthenticationFlowRepresentation `json:"authenticationFlows,omitempty"`
AuthenticatorConfig *AuthenticatorConfigRepresentation `json:"authenticatorConfig,omitempty"`
BrowserFlow *string `json:"browserFlow,omitempty"`
BrowserSecurityHeaders *map[string]interface{} `json:"browserSecurityHeaders,omitempty"`
BruteForceProtected *bool `json:"bruteForceProtected,omitempty"`
ClientAuthenticationFlow *string `json:"clientAuthenticationFlow,omitempty"`
ClientScopeMappings *map[string]interface{} `json:"clientScopeMappings,omitempty"`
ClientTemplates *ClientTemplateRepresentation `json:"clientTemplates,omitempty"`
Clients *ClientRepresentation `json:"clients,omitempty"`
Components *MultivaluedHashMap `json:"components,omitempty"`
DefaultGroups *[]string `json:"defaultGroups,omitempty"`
DefaultLocale *string `json:"defaultLocale,omitempty"`
DefaultRoles *[]string `json:"defaultRoles,omitempty"`
DirectGrantFlow *string `json:"directGrantFlow,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
DisplayNameHtml *string `json:"displayNameHtml,omitempty"`
DockerAuthenticationFlow *string `json:"dockerAuthenticationFlow,omitempty"`
DuplicateEmailsAllowed *bool `json:"duplicateEmailsAllowed,omitempty"`
EditUsernameAllowed *bool `json:"editUsernameAllowed,omitempty"`
EmailTheme *string `json:"emailTheme,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
EnabledEventTypes *[]string `json:"enabledEventTypes,omitempty"`
EventsEnabled *bool `json:"eventsEnabled,omitempty"`
EventsExpiration *int64 `json:"eventsExpiration,omitempty"`
EventsListeners *[]string `json:"eventsListeners,omitempty"`
FailureFactor *int32 `json:"failureFactor,omitempty"`
FederatedUsers *UserRepresentation `json:"federatedUsers,omitempty"`
Groups *GroupRepresentation `json:"groups,omitempty"`
Id *string `json:"id,omitempty"`
IdentityProviderMappers *IdentityProviderMapperRepresentation `json:"identityProviderMappers,omitempty"`
IdentityProviders *IdentityProviderRepresentation `json:"identityProviders,omitempty"`
InternationalizationEnabled *bool `json:"internationalizationEnabled,omitempty"`
KeycloakVersion *string `json:"keycloakVersion,omitempty"`
LoginTheme *string `json:"loginTheme,omitempty"`
LoginWithEmailAllowed *bool `json:"loginWithEmailAllowed,omitempty"`
MaxDeltaTimeSeconds *int32 `json:"maxDeltaTimeSeconds,omitempty"`
MaxFailureWaitSeconds *int32 `json:"maxFailureWaitSeconds,omitempty"`
MinimumQuickLoginWaitSeconds *int32 `json:"minimumQuickLoginWaitSeconds,omitempty"`
NotBefore *int32 `json:"notBefore,omitempty"`
OfflineSessionIdleTimeout *int32 `json:"offlineSessionIdleTimeout,omitempty"`
OtpPolicyAlgorithm *string `json:"otpPolicyAlgorithm,omitempty"`
OtpPolicyDigits *int32 `json:"otpPolicyDigits,omitempty"`
OtpPolicyInitialCounter *int32 `json:"otpPolicyInitialCounter,omitempty"`
OtpPolicyLookAheadWindow *int32 `json:"otpPolicyLookAheadWindow,omitempty"`
OtpPolicyPeriod *int32 `json:"otpPolicyPeriod,omitempty"`
OtpPolicyType *string `json:"otpPolicyType,omitempty"`
PasswordPolicy *string `json:"passwordPolicy,omitempty"`
PermanentLockout *bool `json:"permanentLockout,omitempty"`
ProtocolMappers *ProtocolMapperRepresentation `json:"protocolMappers,omitempty"`
QuickLoginCheckMilliSeconds *int64 `json:"quickLoginCheckMilliSeconds,omitempty"`
Realm *string `json:"realm,omitempty"`
RegistrationAllowed *bool `json:"registrationAllowed,omitempty"`
RegistrationEmailAsUsername *bool `json:"registrationEmailAsUsername,omitempty"`
RegistrationFlow *string `json:"registrationFlow,omitempty"`
RememberMe *bool `json:"rememberMe,omitempty"`
RequiredActions *RequiredActionProviderRepresentation `json:"requiredActions,omitempty"`
ResetCredentialsFlow *string `json:"resetCredentialsFlow,omitempty"`
ResetPasswordAllowed *bool `json:"resetPasswordAllowed,omitempty"`
RevokeRefreshToken *bool `json:"revokeRefreshToken,omitempty"`
Roles *RolesRepresentation `json:"roles,omitempty"`
ScopeMappings *ScopeMappingRepresentation `json:"scopeMappings,omitempty"`
SmtpServer *map[string]interface{} `json:"smtpServer,omitempty"`
SslRequired *string `json:"sslRequired,omitempty"`
SsoSessionIdleTimeout *int32 `json:"ssoSessionIdleTimeout,omitempty"`
SsoSessionMaxLifespan *int32 `json:"ssoSessionMaxLifespan,omitempty"`
SupportedLocales *[]string `json:"supportedLocales,omitempty"`
UserFederationMappers *UserFederationMapperRepresentation `json:"userFederationMappers,omitempty"`
UserFederationProviders *UserFederationProviderRepresentation `json:"userFederationProviders,omitempty"`
Users *UserRepresentation `json:"users,omitempty"`
VerifyEmail *bool `json:"verifyEmail,omitempty"`
WaitIncrementSeconds *int32 `json:"waitIncrementSeconds,omitempty"`
}
type RequiredActionProviderRepresentation struct {
Alias *string `json:"alias,omitempty"`
Config *map[string]interface{} `json:"config,omitempty"`
DefaultAction *bool `json:"defaultAction,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Name *string `json:"name,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
}
type ResourceOwnerRepresentation struct {
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
}
type ResourceRepresentation struct {
Id *string `json:"id,omitempty"`
Icon_uri *string `json:"icon_uri,omitempty"`
Name *string `json:"name,omitempty"`
Owner *ResourceOwnerRepresentation `json:"owner,omitempty"`
Policies *PolicyRepresentation `json:"policies,omitempty"`
Scopes *ScopeRepresentation `json:"scopes,omitempty"`
Type *string `json:"type,omitempty"`
TypedScopes *ScopeRepresentation `json:"typedScopes,omitempty"`
Uri *string `json:"uri,omitempty"`
}
type ResourceServerRepresentation struct {
AllowRemoteResourceManagement *bool `json:"allowRemoteResourceManagement,omitempty"`
ClientId *string `json:"clientId,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Policies *PolicyRepresentation `json:"policies,omitempty"`
PolicyEnforcementMode *string `json:"policyEnforcementMode,omitempty"`
Resources *ResourceRepresentation `json:"resources,omitempty"`
Scopes *ScopeRepresentation `json:"scopes,omitempty"`
}
type RoleRepresentation struct {
ClientRole *bool `json:"clientRole,omitempty"`
Composite *bool `json:"composite,omitempty"`
Composites *RoleRepresentation_Composites `json:"composites,omitempty"`
ContainerId *string `json:"containerId,omitempty"`
Description *string `json:"description,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
ScopeParamRequired *bool `json:"scopeParamRequired,omitempty"`
}
type RoleRepresentation_Composites struct {
Client *map[string]interface{} `json:"client,omitempty"`
Realm *[]string `json:"realm,omitempty"`
}
type RolesRepresentation struct {
Client *map[string]interface{} `json:"client,omitempty"`
Realm *RoleRepresentation `json:"realm,omitempty"`
}
type ScopeMappingRepresentation struct {
Client *string `json:"client,omitempty"`
ClientTemplate *string `json:"clientTemplate,omitempty"`
Roles *[]string `json:"roles,omitempty"`
Self *string `json:"self,omitempty"`
}
type ScopeRepresentation struct {
IconUri *string `json:"iconUri,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Policies *PolicyRepresentation `json:"policies,omitempty"`
Resources *ResourceRepresentation `json:"resources,omitempty"`
}
type ServerInfoRepresentation struct {
BuiltinProtocolMappers *map[string]interface{} `json:"builtinProtocolMappers,omitempty"`
ClientImporters *map[string]interface{} `json:"clientImporters,omitempty"`
ClientInstallations *map[string]interface{} `json:"clientInstallations,omitempty"`
ComponentTypes *map[string]interface{} `json:"componentTypes,omitempty"`
Enums *map[string]interface{} `json:"enums,omitempty"`
IdentityProviders *map[string]interface{} `json:"identityProviders,omitempty"`
MemoryInfo *MemoryInfoRepresentation `json:"memoryInfo,omitempty"`
PasswordPolicies *PasswordPolicyTypeRepresentation `json:"passwordPolicies,omitempty"`
ProfileInfo *ProfileInfoRepresentation `json:"profileInfo,omitempty"`
ProtocolMapperTypes *map[string]interface{} `json:"protocolMapperTypes,omitempty"`
Providers *map[string]interface{} `json:"providers,omitempty"`
SocialProviders *map[string]interface{} `json:"socialProviders,omitempty"`
SystemInfo *SystemInfoRepresentation `json:"systemInfo,omitempty"`
Themes *map[string]interface{} `json:"themes,omitempty"`
}
type SpiInfoRepresentation struct {
Internal *bool `json:"internal,omitempty"`
Providers *map[string]interface{} `json:"providers,omitempty"`
}
type SynchronizationResult struct {
Added *int32 `json:"added,omitempty"`
Failed *int32 `json:"failed,omitempty"`
Ignored *bool `json:"ignored,omitempty"`
Removed *int32 `json:"removed,omitempty"`
Status *string `json:"status,omitempty"`
Updated *int32 `json:"updated,omitempty"`
}
type SystemInfoRepresentation struct {
FileEncoding *string `json:"fileEncoding,omitempty"`
JavaHome *string `json:"javaHome,omitempty"`
JavaRuntime *string `json:"javaRuntime,omitempty"`
JavaVendor *string `json:"javaVendor,omitempty"`
JavaVersion *string `json:"javaVersion,omitempty"`
JavaVm *string `json:"javaVm,omitempty"`
JavaVmVersion *string `json:"javaVmVersion,omitempty"`
OsArchitecture *string `json:"osArchitecture,omitempty"`
OsName *string `json:"osName,omitempty"`
OsVersion *string `json:"osVersion,omitempty"`
ServerTime *string `json:"serverTime,omitempty"`
Uptime *string `json:"uptime,omitempty"`
UptimeMillis *int64 `json:"uptimeMillis,omitempty"`
UserDir *string `json:"userDir,omitempty"`
UserLocale *string `json:"userLocale,omitempty"`
UserName *string `json:"userName,omitempty"`
UserTimezone *string `json:"userTimezone,omitempty"`
Version *string `json:"version,omitempty"`
}
type UserConsentRepresentation struct {
ClientId *string `json:"clientId,omitempty"`
CreatedDate *int64 `json:"createdDate,omitempty"`
GrantedClientRoles *map[string]interface{} `json:"grantedClientRoles,omitempty"`
GrantedProtocolMappers *map[string]interface{} `json:"grantedProtocolMappers,omitempty"`
GrantedRealmRoles *[]string `json:"grantedRealmRoles,omitempty"`
LastUpdatedDate *int64 `json:"lastUpdatedDate,omitempty"`
}
type UserFederationMapperRepresentation struct {
Config *map[string]interface{} `json:"config,omitempty"`
FederationMapperType *string `json:"federationMapperType,omitempty"`
FederationProviderDisplayName *string `json:"federationProviderDisplayName,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
}
type UserFederationProviderRepresentation struct {
ChangedSyncPeriod *int32 `json:"changedSyncPeriod,omitempty"`
Config *map[string]interface{} `json:"config,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
FullSyncPeriod *int32 `json:"fullSyncPeriod,omitempty"`
Id *string `json:"id,omitempty"`
LastSync *int32 `json:"lastSync,omitempty"`
Priority *int32 `json:"priority,omitempty"`
ProviderName *string `json:"providerName,omitempty"`
}
type UserRepresentation struct {
Access *map[string]interface{} `json:"access,omitempty"`
Attributes *map[string]interface{} `json:"attributes,omitempty"`
ClientConsents *UserConsentRepresentation `json:"clientConsents,omitempty"`
ClientRoles *map[string]interface{} `json:"clientRoles,omitempty"`
CreatedTimestamp *int64 `json:"createdTimestamp,omitempty"`
Credentials *CredentialRepresentation `json:"credentials,omitempty"`
DisableableCredentialTypes *[]string `json:"disableableCredentialTypes,omitempty"`
Email *string `json:"email,omitempty"`
EmailVerified *bool `json:"emailVerified,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
FederatedIdentities *FederatedIdentityRepresentation `json:"federatedIdentities,omitempty"`
FederationLink *string `json:"federationLink,omitempty"`
FirstName *string `json:"firstName,omitempty"`
Groups *[]string `json:"groups,omitempty"`
Id *string `json:"id,omitempty"`
LastName *string `json:"lastName,omitempty"`
Origin *string `json:"origin,omitempty"`
RealmRoles *[]string `json:"realmRoles,omitempty"`
RequiredActions *[]string `json:"requiredActions,omitempty"`
Self *string `json:"self,omitempty"`
ServiceAccountClientId *string `json:"serviceAccountClientId,omitempty"`
Username *string `json:"username,omitempty"`
}
type UserSessionRepresentation struct {
Clients *map[string]interface{} `json:"clients,omitempty"`
Id *string `json:"id,omitempty"`
IpAddress *string `json:"ipAddress,omitempty"`
LastAccess *int64 `json:"lastAccess,omitempty"`
Start *int64 `json:"start,omitempty"`
UserId *string `json:"userId,omitempty"`
Username *string `json:"username,omitempty"`
}

29
client/realms.go

@ -0,0 +1,29 @@
package client
import (
"github.com/pkg/errors"
gentleman "gopkg.in/h2non/gentleman.v2"
"encoding/json"
)
func (c *client) GetRealms() ([]map[string]interface{}, error) {
var getRealms_Path string = "/auth/admin/realms"
var resp *gentleman.Response
{
var err error
resp, err = c.do(getRealms_Path)
if err != nil {
return nil, errors.Wrap(err, "Get Realms failed.")
}
}
var result []map[string]interface{}
{
var err error
err = json.Unmarshal(resp.Bytes(), &result)
if err != nil {
return nil, errors.Wrap(err, "Get Realms failed to unmarshal response.")
}
}
return result, nil
}

29
client/users.go

@ -0,0 +1,29 @@
package client
import (
"fmt"
"gopkg.in/h2non/gentleman.v2"
"github.com/pkg/errors"
"encoding/json"
)
func (c *client)GetUsers(realm string) ([]UserRepresentation, error) {
var getUsers_Path string = fmt.Sprintf("/auth/admin/realms/%s/users", realm)
var resp *gentleman.Response
{
var err error
resp, err = c.do(getUsers_Path)
if err != nil {
return nil, errors.Wrap(err, "Get Realms failed.")
}
}
var result []UserRepresentation
{
var err error
err = json.Unmarshal(resp.Bytes(), &result)
if err != nil {
return nil, errors.Wrap(err, "Get Users failed to unmarshal response.")
}
}
return result, nil
}

4
utils/.idea/misc.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.5.3 virtualenv at ~/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils" project-jdk-type="Python SDK" />
</project>

8
utils/.idea/modules.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/utils.iml" filepath="$PROJECT_DIR$/.idea/utils.iml" />
</modules>
</component>
</project>

11
utils/.idea/utils.iml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.5.3 virtualenv at ~/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>

313
utils/.idea/workspace.xml

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4beebe65-bbd6-42c2-bc02-1c9632811740" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="file_parser.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/file_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="301">
<caret line="68" column="26" lean-forward="false" selection-start-line="68" selection-start-column="26" selection-end-line="68" selection-end-column="26" />
<folding>
<element signature="e#24#34#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="html_parser.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/html_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="23" column="21" lean-forward="true" selection-start-line="23" selection-start-column="21" selection-end-line="23" selection-end-column="21" />
<folding>
<element signature="e#24#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>print</find>
</findStrings>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/htmlParser.py" />
<option value="$PROJECT_DIR$/html_parser.py" />
<option value="$PROJECT_DIR$/file_parser.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="27" />
<option name="width" value="1920" />
<option name="height" value="1053" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="utils" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="utils" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$/bin/python3" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Python.html_parser">
<configuration default="false" name="html_parser" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="utils" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/html_parser.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<method />
</configuration>
<configuration default="true" type="PythonConfigurationType" factoryName="Python">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="utils" />
<option name="SCRIPT_NAME" value="" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<method />
</configuration>
<configuration default="true" type="Tox" factoryName="Tox">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="utils" />
<method />
</configuration>
<configuration default="true" type="tests" factoryName="Doctests">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="utils" />
<option name="SCRIPT_NAME" value="" />
<option name="CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="FOLDER_NAME" value="" />
<option name="TEST_TYPE" value="TEST_SCRIPT" />
<option name="PATTERN" value="" />
<option name="USE_PATTERN" value="false" />
<method />
</configuration>
<configuration default="true" type="tests" factoryName="Unittests">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="utils" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;.&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method />
</configuration>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Python.html_parser" />
</list>
<recent_temporary>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Python.html_parser" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="4beebe65-bbd6-42c2-bc02-1c9632811740" name="Default" comment="" />
<created>1500550169408</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1500550169408</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="27" width="1920" height="1053" extended-state="6" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3290735" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/file_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="920">
<caret line="46" column="29" lean-forward="false" selection-start-line="46" selection-start-column="29" selection-end-line="46" selection-end-column="29" />
<folding>
<element signature="e#24#34#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/html_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="580">
<caret line="30" column="42" lean-forward="true" selection-start-line="30" selection-start-column="42" selection-end-line="30" selection-end-column="42" />
<folding>
<element signature="e#24#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/file_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="420">
<caret line="21" column="27" lean-forward="false" selection-start-line="21" selection-start-column="27" selection-end-line="21" selection-end-column="27" />
<folding>
<element signature="e#24#34#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/html_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="3" column="0" lean-forward="false" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
<folding>
<element signature="e#24#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/html_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="23" column="21" lean-forward="true" selection-start-line="23" selection-start-column="21" selection-end-line="23" selection-end-column="21" />
<folding>
<element signature="e#24#53#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/file_parser.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="301">
<caret line="68" column="26" lean-forward="false" selection-start-line="68" selection-start-column="26" selection-end-line="68" selection-end-column="26" />
<folding>
<element signature="e#24#34#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

78
utils/bin/activate

@ -0,0 +1,78 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
unset -f pydoc >/dev/null 2>&1
# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
fi
export PS1
fi
# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc
pydoc () {
python -m pydoc "$@"
}
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi

36
utils/bin/activate.csh

@ -0,0 +1,36 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
if ("" != "") then
set env_name = ""
else
set env_name = `basename "$VIRTUAL_ENV"`
endif
# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt"
set prompt = "[$env_name] $prompt"
endif
unset env_name
alias pydoc python -m pydoc
rehash

76
utils/bin/activate.fish

@ -0,0 +1,76 @@
# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
# Do not run it directly.
function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
set -l fish_function_path
# Erase virtualenv's `fish_prompt` and restore the original.
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
end
set -e VIRTUAL_ENV
if test "$argv[1]" != 'nondestructive'
# Self-destruct!
functions -e pydoc
functions -e deactivate
end
end
# Unset irrelevant variables.
deactivate nondestructive
set -gx VIRTUAL_ENV "/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
# Unset `$PYTHONHOME` if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
function pydoc
python -m pydoc $argv
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
functions -c fish_prompt _old_fish_prompt
function fish_prompt
# Save the current $status, for fish_prompts that display it.
set -l old_status $status
# Prompt override provided?
# If not, just prepend the environment name.
if test -n ""
printf '%s%s' "" (set_color normal)
else
printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV")
end
# Restore the original $status
echo "exit $old_status" | source
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end

34
utils/bin/activate_this.py

@ -0,0 +1,34 @@
"""By using execfile(this_file, dict(__file__=this_file)) you will
activate this virtualenv environment.
This can be used when you must use an existing Python interpreter, not
the virtualenv bin/python
"""
try:
__file__
except NameError:
raise AssertionError(
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
import sys
import os
old_os_path = os.environ.get('PATH', '')
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path

11
utils/bin/chardetect

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from chardet.cli.chardetect import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
utils/bin/easy_install

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
utils/bin/easy_install-3.5

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
utils/bin/pip

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
utils/bin/pip3

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
utils/bin/pip3.5

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

1
utils/bin/python

@ -0,0 +1 @@
python3

78
utils/bin/python-config

@ -0,0 +1,78 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python
import sys
import getopt
import sysconfig
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
'ldflags', 'help']
if sys.version_info >= (3, 2):
valid_opts.insert(-1, 'extension-suffix')
valid_opts.append('abiflags')
if sys.version_info >= (3, 3):
valid_opts.append('configdir')
def exit_with_usage(code=1):
sys.stderr.write("Usage: {0} [{1}]\n".format(
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)))
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
except getopt.error:
exit_with_usage()
if not opts:
exit_with_usage()
pyver = sysconfig.get_config_var('VERSION')
getvar = sysconfig.get_config_var
opt_flags = [flag for (flag, val) in opts]
if '--help' in opt_flags:
exit_with_usage(code=0)
for opt in opt_flags:
if opt == '--prefix':
print(sysconfig.get_config_var('prefix'))
elif opt == '--exec-prefix':
print(sysconfig.get_config_var('exec_prefix'))
elif opt in ('--includes', '--cflags'):
flags = ['-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude')]
if opt == '--cflags':
flags.extend(getvar('CFLAGS').split())
print(' '.join(flags))
elif opt in ('--libs', '--ldflags'):
abiflags = getattr(sys, 'abiflags', '')
libs = ['-lpython' + pyver + abiflags]
libs += getvar('LIBS').split()
libs += getvar('SYSLIBS').split()
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags':
if not getvar('Py_ENABLE_SHARED'):
libs.insert(0, '-L' + getvar('LIBPL'))
if not getvar('PYTHONFRAMEWORK'):
libs.extend(getvar('LINKFORSHARED').split())
print(' '.join(libs))
elif opt == '--extension-suffix':
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
if ext_suffix is None:
ext_suffix = sysconfig.get_config_var('SO')
print(ext_suffix)
elif opt == '--abiflags':
if not getattr(sys, 'abiflags', None):
exit_with_usage()
print(sys.abiflags)
elif opt == '--configdir':
print(sysconfig.get_config_var('LIBPL'))

BIN
utils/bin/python3

Binary file not shown.

1
utils/bin/python3.5

@ -0,0 +1 @@
python3

11
utils/bin/wheel

@ -0,0 +1,11 @@
#!/root/cloudtrust/go/src/github.com/elca-kairos-py/keycloak/utils/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from wheel.tool import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

91
utils/file_parser.py

@ -0,0 +1,91 @@
#!/usr/bin/env python3
import sys
import re
#Parameter required or optional
OPT_TOKEN = 'optional'
REQ_TOKEN = 'required'
REQ_TOKENS = set([OPT_TOKEN,REQ_TOKEN])
#Direct Type tokens (directly mapped to golang)
DIRECT_INT_TYPE_TOKENS = set(['int16','int32','int64'])
#Typed Arrays
STL_OPEN_TOKEN = '<'
STL_CLOSE_TOKEN = '>'
ARRAY_TOKEN = 'array'
#Type tokens
MAP_TYPE_TOKEN = 'Map'
INT_TYPE_TOKEN = 'integer'
BOOL_TYPE_TOKEN = 'boolean'
STRING_TYPE_TOKEN = 'string'
ENUM_TYPE_TOKEN = 'enum'
TYPE_TOKENS = set([MAP_TYPE_TOKEN,INT_TYPE_TOKEN,BOOL_TYPE_TOKEN,STRING_TYPE_TOKEN, ENUM_TYPE_TOKEN])
MAP_TOKEN_TO_GO = {
MAP_TYPE_TOKEN:"map[string]interface{}",
BOOL_TYPE_TOKEN:"bool",
STRING_TYPE_TOKEN:"string",
ENUM_TYPE_TOKEN:"string",
}
def panic(*args):
eprint(*args)
sys.exit(1)
def eprint(*args):
print(*args, file=sys.stderr)
def to_go_array(go_type):
return "[]%s" % go_type
def is_req(split_line):
req = split_line.pop(0)
if req not in REQ_TOKENS:
panic("Token %s does not match requirement tokens" % req)
if req == REQ_TOKEN:
return True
return False
def get_type(split_line):
token = split_line.pop(0)
if token in TYPE_TOKENS:
if token == INT_TYPE_TOKEN:
token = split_line.pop()
if token not in DIRECT_INT_TYPE_TOKENS:
panic("%s is wrong int type!" % token)
return token
return MAP_TOKEN_TO_GO[token]
if token == STL_OPEN_TOKEN:
return to_go_array(get_type(split_line))
return token
def parse_line(split_line):
field_name = split_line.pop(0)
if field_name == type:
field_name = "typ"
exported_field_name = field_name[0].upper() + field_name[1:]
required = is_req(split_line)
go_type = get_type(split_line)
if required:
res = """\t%s *%s `json:"%s"`\n""" % (exported_field_name,go_type,field_name)
else:
res = """\t%s *%s `json:"%s,omitempty"`\n""" % (exported_field_name,go_type,field_name)
return res
def main():
if len(sys.argv) < 2:
eprint("Usage : %s file" % sys.argv[0])
return
res = "type %s struct { \n" % sys.argv[1]
with open(sys.argv[1], 'r') as table:
for line in table.readlines():
res += parse_line([x for x in re.split('\s+|\(|\)',line) if x])
res += "}\n"
print(res)
if __name__ == "__main__":
main()

38
utils/html_parser.py

@ -0,0 +1,38 @@
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
keycloak_doc = requests.get("http://www.keycloak.org/docs-api/3.2/rest-api/index.html").text
soup = BeautifulSoup(keycloak_doc, "lxml")
for div in soup.body.find_all('div'):
if div.h2:
if div.h2.string == "Definitions":
definitions=div.div
break
for div in definitions.find_all('div'):
name = div.h3.string
print("\n",name,"\n")
#print(div)
with open("./resources/{}".format(name), "w") as f :
try:
for tr in div.table.tbody.find_all('tr'):
tds = tr.find_all('td')
field_name = tds[0].p.strong.string
field_req = tds[0].p.em.string
if tds[1].p.string:
field_type = tds[1].p.string
else:
field_type = tds[1].p.a.string
if field_req not in set(['optional','required']):
field_req = 'optional'
print(field_name + ' ' + field_req + ' ' + field_type)
f.write(field_name + ' ' + field_req + ' ' + field_type + '\n')
except :
print("WARNING!!!", name)
#print(definitions.find_all('div')[-1])

1
utils/include/python3.5m

@ -0,0 +1 @@
/usr/include/python3.5m

1
utils/lib/python3.5/__future__.py

@ -0,0 +1 @@
/usr/lib64/python3.5/__future__.py

BIN
utils/lib/python3.5/__pycache__/__future__.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/abc.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/base64.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/bisect.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/codecs.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/copy.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/copyreg.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/fnmatch.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/functools.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/genericpath.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/hashlib.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/heapq.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/hmac.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/imp.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/io.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/keyword.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/linecache.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/locale.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/operator.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/os.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/posixpath.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/random.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/re.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/reprlib.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/shutil.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/site.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/sre_compile.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/sre_constants.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/sre_parse.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/stat.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/struct.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/tarfile.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/tempfile.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/token.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/tokenize.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/types.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/warnings.cpython-35.pyc

Binary file not shown.

BIN
utils/lib/python3.5/__pycache__/weakref.cpython-35.pyc

Binary file not shown.

1
utils/lib/python3.5/_bootlocale.py

@ -0,0 +1 @@
/usr/lib64/python3.5/_bootlocale.py

1
utils/lib/python3.5/_collections_abc.py

@ -0,0 +1 @@
/usr/lib64/python3.5/_collections_abc.py

1
utils/lib/python3.5/_dummy_thread.py

@ -0,0 +1 @@
/usr/lib64/python3.5/_dummy_thread.py

1
utils/lib/python3.5/_weakrefset.py

@ -0,0 +1 @@
/usr/lib64/python3.5/_weakrefset.py

1
utils/lib/python3.5/abc.py

@ -0,0 +1 @@
/usr/lib64/python3.5/abc.py

1
utils/lib/python3.5/base64.py

@ -0,0 +1 @@
/usr/lib64/python3.5/base64.py

1
utils/lib/python3.5/bisect.py

@ -0,0 +1 @@
/usr/lib64/python3.5/bisect.py

1
utils/lib/python3.5/codecs.py

@ -0,0 +1 @@
/usr/lib64/python3.5/codecs.py

1
utils/lib/python3.5/collections

@ -0,0 +1 @@
/usr/lib64/python3.5/collections

1
utils/lib/python3.5/config-3.5m

@ -0,0 +1 @@
/usr/lib64/python3.5/config-3.5m

1
utils/lib/python3.5/copy.py

@ -0,0 +1 @@
/usr/lib64/python3.5/copy.py

1
utils/lib/python3.5/copyreg.py

@ -0,0 +1 @@
/usr/lib64/python3.5/copyreg.py

101
utils/lib/python3.5/distutils/__init__.py

@ -0,0 +1,101 @@
import os
import sys
import warnings
import imp
import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib
# Important! To work on pypy, this must be a module that resides in the
# lib-python/modified-x.y.z directory
dirname = os.path.dirname
distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
warnings.warn(
"The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
else:
__path__.insert(0, distutils_path)
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY))
# Copy the relevant attributes
try:
__revision__ = real_distutils.__revision__
except AttributeError:
pass
__version__ = real_distutils.__version__
from distutils import dist, sysconfig
try:
basestring
except NameError:
basestring = str
## patch build_ext (distutils doesn't know how to get the libs directory
## path on windows - it hardcodes the paths around the patched sys.prefix)
if sys.platform == 'win32':
from distutils.command.build_ext import build_ext as old_build_ext
class build_ext(old_build_ext):
def finalize_options (self):
if self.library_dirs is None:
self.library_dirs = []
elif isinstance(self.library_dirs, basestring):
self.library_dirs = self.library_dirs.split(os.pathsep)
self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs"))
old_build_ext.finalize_options(self)
from distutils.command import build_ext as build_ext_module
build_ext_module.build_ext = build_ext
## distutils.dist patches:
old_find_config_files = dist.Distribution.find_config_files
def find_config_files(self):
found = old_find_config_files(self)
system_distutils = os.path.join(distutils_path, 'distutils.cfg')
#if os.path.exists(system_distutils):
# found.insert(0, system_distutils)
# What to call the per-user config file
if os.name == 'posix':
user_filename = ".pydistutils.cfg"
else:
user_filename = "pydistutils.cfg"
user_filename = os.path.join(sys.prefix, user_filename)
if os.path.isfile(user_filename):
for item in list(found):
if item.endswith('pydistutils.cfg'):
found.remove(item)
found.append(user_filename)
return found
dist.Distribution.find_config_files = find_config_files
## distutils.sysconfig patches:
old_get_python_inc = sysconfig.get_python_inc
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
if prefix is None:
prefix = sys.real_prefix
return old_get_python_inc(plat_specific, prefix)
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
sysconfig.get_python_inc = sysconfig_get_python_inc
old_get_python_lib = sysconfig.get_python_lib
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
if standard_lib and prefix is None:
prefix = sys.real_prefix
return old_get_python_lib(plat_specific, standard_lib, prefix)
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
sysconfig.get_python_lib = sysconfig_get_python_lib
old_get_config_vars = sysconfig.get_config_vars
def sysconfig_get_config_vars(*args):
real_vars = old_get_config_vars(*args)
if sys.platform == 'win32':
lib_dir = os.path.join(sys.real_prefix, "libs")
if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars:
real_vars['LIBDIR'] = lib_dir # asked for all
elif isinstance(real_vars, list) and 'LIBDIR' in args:
real_vars = real_vars + [lib_dir] # asked for list
return real_vars
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
sysconfig.get_config_vars = sysconfig_get_config_vars

BIN
utils/lib/python3.5/distutils/__pycache__/__init__.cpython-35.pyc

Binary file not shown.

6
utils/lib/python3.5/distutils/distutils.cfg

@ -0,0 +1,6 @@
# This is a config file local to this virtualenv installation
# You may include options that will be used by all distutils commands,
# and by easy_install. For instance:
#
# [easy_install]
# find_links = http://mylocalsite

1
utils/lib/python3.5/encodings

@ -0,0 +1 @@
/usr/lib64/python3.5/encodings

1
utils/lib/python3.5/fnmatch.py

@ -0,0 +1 @@
/usr/lib64/python3.5/fnmatch.py

1
utils/lib/python3.5/functools.py

@ -0,0 +1 @@
/usr/lib64/python3.5/functools.py

1
utils/lib/python3.5/genericpath.py

@ -0,0 +1 @@
/usr/lib64/python3.5/genericpath.py

1
utils/lib/python3.5/hashlib.py

@ -0,0 +1 @@
/usr/lib64/python3.5/hashlib.py

1
utils/lib/python3.5/heapq.py

@ -0,0 +1 @@
/usr/lib64/python3.5/heapq.py

1
utils/lib/python3.5/hmac.py

@ -0,0 +1 @@
/usr/lib64/python3.5/hmac.py

1
utils/lib/python3.5/imp.py

@ -0,0 +1 @@
/usr/lib64/python3.5/imp.py

1
utils/lib/python3.5/importlib

@ -0,0 +1 @@
/usr/lib64/python3.5/importlib

1
utils/lib/python3.5/io.py

@ -0,0 +1 @@
/usr/lib64/python3.5/io.py

1
utils/lib/python3.5/keyword.py

@ -0,0 +1 @@
/usr/lib64/python3.5/keyword.py

1
utils/lib/python3.5/lib-dynload

@ -0,0 +1 @@
/usr/lib64/python3.5/lib-dynload

1
utils/lib/python3.5/linecache.py

@ -0,0 +1 @@
/usr/lib64/python3.5/linecache.py

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save