-
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?
Changes from all commits
9216de6
d7d007f
0e59093
0d6f275
057c4d0
3c68034
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
realm string | ||||||||||||||||||||
clientCredentials *ClientCredentials | ||||||||||||||||||||
httpClient *http.Client | ||||||||||||||||||||
|
@@ -60,7 +61,7 @@ var redHatSSO7VersionMap = map[int]string{ | |||||||||||||||||||
4: "9.0.17", | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
func NewKeycloakClient(ctx context.Context, url, basePath, clientId, clientSecret, realm, username, password string, initialLogin bool, clientTimeout int, caCert string, tlsInsecureSkipVerify bool, userAgent string, redHatSSO bool, additionalHeaders map[string]string) (*KeycloakClient, error) { | ||||||||||||||||||||
func NewKeycloakClient(ctx context.Context, url, basePath, adminUrl, clientId, clientSecret, realm, username, password string, initialLogin bool, clientTimeout int, caCert string, tlsInsecureSkipVerify bool, userAgent string, redHatSSO bool, additionalHeaders map[string]string) (*KeycloakClient, error) { | ||||||||||||||||||||
clientCredentials := &ClientCredentials{ | ||||||||||||||||||||
ClientId: clientId, | ||||||||||||||||||||
ClientSecret: clientSecret, | ||||||||||||||||||||
|
@@ -83,9 +84,13 @@ func NewKeycloakClient(ctx context.Context, url, basePath, clientId, clientSecre | |||||||||||||||||||
if err != nil { | ||||||||||||||||||||
return nil, fmt.Errorf("failed to create http client: %v", err) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
baseUrl := url + basePath | ||||||||||||||||||||
if adminUrl != "" { | ||||||||||||||||||||
baseUrl = adminUrl + basePath | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+87
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
keycloakClient := KeycloakClient{ | ||||||||||||||||||||
baseUrl: url + basePath, | ||||||||||||||||||||
baseUrl: baseUrl, | ||||||||||||||||||||
authnUrl: url + basePath, | ||||||||||||||||||||
Comment on lines
+92
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
clientCredentials: clientCredentials, | ||||||||||||||||||||
httpClient: httpClient, | ||||||||||||||||||||
initialLogin: initialLogin, | ||||||||||||||||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
accessTokenData := keycloakClient.getAuthenticationFormData() | ||||||||||||||||||||
|
||||||||||||||||||||
tflog.Debug(ctx, "Login request", map[string]interface{}{ | ||||||||||||||||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
refreshTokenData := keycloakClient.getAuthenticationFormData() | ||||||||||||||||||||
|
||||||||||||||||||||
tflog.Debug(ctx, "Refresh request", map[string]interface{}{ | ||||||||||||||||||||
|
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.