-
Notifications
You must be signed in to change notification settings - Fork 356
feat: add admin url variable to separate authn and admin api urls #1129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…on and admin api calls to the correct URL Signed-off-by: frpicard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frpicard I finally managed to have a look at your PR. It looks good, I just have some nitpicks to increase readability. If you are fine with my suggested changes, I am happy to merge your PR.
@@ -79,6 +79,7 @@ The following arguments are supported: | |||
|
|||
- `client_id` - (Required) The `client_id` for the client that was created in the "Keycloak Setup" section. Use the `admin-cli` client if you are using the password grant. Defaults to the environment variable `KEYCLOAK_CLIENT_ID`. | |||
- `url` - (Required) The URL of the Keycloak instance, before `/auth/admin`. Defaults to the environment variable `KEYCLOAK_URL`. | |||
- `admin_url` - (Optional) The admin URL of the Keycloak instance if different from the main URL, before `/auth/admin`. Defaults to the environment variable `KEYCLOAK_ADMIN_URL`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `admin_url` - (Optional) The admin URL of the Keycloak instance if different from the main URL, before `/auth/admin`. Defaults to the environment variable `KEYCLOAK_ADMIN_URL`. | |
- `admin_url` - (Optional) The admin URL of the Keycloak instance if different from the base URL, before `/auth/admin`. Defaults to the environment variable `KEYCLOAK_ADMIN_URL`. |
baseUrl := url + basePath | ||
if adminUrl != "" { | ||
baseUrl = adminUrl + basePath | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
baseUrl := url + basePath | |
if adminUrl != "" { | |
baseUrl = adminUrl + basePath | |
} | |
authUrl := url + basePath | |
baseUrl := authUrl | |
if adminUrl != "" { | |
baseUrl = adminUrl + basePath | |
} |
@@ -26,6 +26,7 @@ import ( | |||
|
|||
type KeycloakClient struct { | |||
baseUrl string | |||
authnUrl string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authnUrl string | |
authUrl string |
baseUrl: baseUrl, | ||
authnUrl: url + basePath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
baseUrl: baseUrl, | |
authnUrl: url + basePath, | |
baseUrl: baseUrl, | |
authUrl: authUrl, |
@@ -112,7 +117,7 @@ func NewKeycloakClient(ctx context.Context, url, basePath, clientId, clientSecre | |||
} | |||
|
|||
func (keycloakClient *KeycloakClient) login(ctx context.Context) error { | |||
accessTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.baseUrl, keycloakClient.realm) | |||
accessTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.authnUrl, keycloakClient.realm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accessTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.authnUrl, keycloakClient.realm) | |
accessTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.authUrl, keycloakClient.realm) |
@@ -203,7 +208,7 @@ func (keycloakClient *KeycloakClient) login(ctx context.Context) error { | |||
} | |||
|
|||
func (keycloakClient *KeycloakClient) Refresh(ctx context.Context) error { | |||
refreshTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.baseUrl, keycloakClient.realm) | |||
refreshTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.authnUrl, keycloakClient.realm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refreshTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.authnUrl, keycloakClient.realm) | |
refreshTokenUrl := fmt.Sprintf(tokenUrl, keycloakClient.authUrl, keycloakClient.realm) |
No description provided.