./capifcore [-port <port (default 8090)>] [-secPort <Secure port (default 4433)>] [-chartMuseumUrl <URL to ChartMuseum>] [-repoName <Helm repo name (default capifcore)>] [-loglevel <log level (default Info)>] [-certPath <Path to certificate>] [-keyPath <Path to private key>]
-Use docker compose file to start Keycloak:
+Use docker compose file to start CAPIF core together with Keycloak:
docker-compose up
+**NOTE!** There is a configuration file in configs/keycloak.yaml with information related to keycloak host, when running locally the host value must be set to localhost (Eg. host: "localhost") and when using docker-compose set value of host to keycloak (Eg. host:"keycloak")
+
+Before using CAPIF API invoker management, an invoker realm must be created in keycloak. Make sure it is created before running CAPIF core. After creating the realm in keycloak, set the name in the keycloak.yaml configuration file.
+
To run CAPIF Core as a K8s pod together with ChartMuseum, start and stop scripts are provided. The pod configurations are provided in the `configs` folder. CAPIF Core is then available on port `31570`.
func (km *KeycloakManager) GetToken(realm string, data map[string][]string) (Jwttoken, error) {
var jwt Jwttoken
- getTokenUrl := km.keycloakServerUrl + "/realms/" + realm + "/protocol/openid-connect/token"
+ realmVal, ok := km.realms[realm]
+ if !ok {
+ log.Errorf("error realm does not exist\n")
+ return jwt, errors.New("realm does not exist")
+ }
+ getTokenUrl := km.keycloakServerUrl + "/realms/" + realmVal + "/protocol/openid-connect/token"
resp, err := http.PostForm(getTokenUrl, data)
if err != nil {
return err
}
- createClientUrl := km.keycloakServerUrl + "/admin/realms/" + realm + "/clients"
+ realmVal, ok := km.realms[realm]
+ if !ok {
+ log.Errorf("error realm does not exist\n")
+ return errors.New("realm does not exist")
+ }
+
+ createClientUrl := km.keycloakServerUrl + "/admin/realms/" + realmVal + "/clients"
newClient := map[string]interface{}{"clientId": clientId, "serviceAccountsEnabled": true}
body, err := json.Marshal(newClient)
return nil, err
}
- createClientUrl, _ := url.Parse(km.keycloakServerUrl + "/admin/realms/" + realm + "/clients")
+ realmVal, ok := km.realms[realm]
+ if !ok {
+ log.Errorf("error realm does not exist\n")
+ return nil, errors.New("realm does not exist")
+ }
+
+ createClientUrl, _ := url.Parse(km.keycloakServerUrl + "/admin/realms/" + realmVal + "/clients")
q := createClientUrl.Query()
q.Add("clientId", clientId)
createClientUrl.RawQuery = q.Encode()