-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Allow override of baseUrl and apiUrl in GitHub identity provider #7021
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
Merged
stianst
merged 4 commits into
keycloak:main
from
nngo:KEYCLOAK-13828-github-enterprise-intergration
Apr 6, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2aa5c0d
KEYCLOAK-13828 Allow override of baseUrl & apiUrl in GitHub identity …
nngo 81cc80f
Remove empty testGetProfileEndpointForValidation() unit test
nngo 7908204
Always show GH baseUrl and apiUrl per PR comment
nngo de8d3c2
Merge remote-tracking branch 'origin/main' into KEYCLOAK-13828-github…
nngo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
services/src/test/java/org/keycloak/social/github/GitHubIdentityProviderTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.keycloak.social.github; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.keycloak.broker.oidc.OAuth2IdentityProviderConfig; | ||
|
||
/** | ||
* Unit test for {@link org.keycloak.social.github.GitHubIdentityProvider}. | ||
* | ||
* @author Neon Ngo | ||
*/ | ||
public class GitHubIdentityProviderTest { | ||
nngo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Test constructor with empty config (i.e. to use default values). | ||
* This also tests GitHubIdentityProvider.getProfileEndpointForValidation(null). | ||
*/ | ||
@Test | ||
public void testGitHubIdentityProvider() { | ||
OAuth2IdentityProviderConfig config = new OAuth2IdentityProviderConfig(); | ||
GitHubIdentityProvider idp = new GitHubIdentityProvider(null, config); | ||
|
||
validateUrls(idp, GitHubIdentityProvider.DEFAULT_BASE_URL, GitHubIdentityProvider.DEFAULT_API_URL); | ||
} | ||
|
||
/** | ||
* Test constructor with config overrides of default base URL and API URL. | ||
*/ | ||
@Test | ||
public void testGitHubIdentityProviderOverrides() { | ||
OAuth2IdentityProviderConfig config = new OAuth2IdentityProviderConfig(); | ||
String baseUrl = "https://test.com"; | ||
String apiUrl = "https://api.test.com"; | ||
config.getConfig().put(GitHubIdentityProvider.BASE_URL_KEY, baseUrl); | ||
config.getConfig().put(GitHubIdentityProvider.API_URL_KEY, apiUrl); | ||
GitHubIdentityProvider idp = new GitHubIdentityProvider(null, config); | ||
|
||
validateUrls(idp, baseUrl, apiUrl); | ||
} | ||
|
||
protected void validateUrls(GitHubIdentityProvider idp, String baseUrl, String apiUrl) { | ||
OAuth2IdentityProviderConfig config = idp.getConfig(); | ||
assertEquals(baseUrl + GitHubIdentityProvider.AUTH_FRAGMENT, config.getAuthorizationUrl()); | ||
assertEquals(baseUrl + GitHubIdentityProvider.TOKEN_FRAGMENT, config.getTokenUrl()); | ||
assertEquals(apiUrl + GitHubIdentityProvider.EMAIL_FRAGMENT, config.getConfig().get(GitHubIdentityProvider.EMAIL_URL_KEY)); | ||
assertEquals(apiUrl + GitHubIdentityProvider.PROFILE_FRAGMENT, config.getUserInfoUrl()); | ||
assertEquals(apiUrl + GitHubIdentityProvider.PROFILE_FRAGMENT, idp.getProfileEndpointForValidation(null)); | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="form-group clearfix block"> | ||
<label class="col-md-2 control-label" for="baseUrl">{{:: 'identity-provider.base-url' | translate}}</label> | ||
<div class="col-md-6"> | ||
<input class="form-control" id="baseUrl" type="text" ng-model="identityProvider.config.baseUrl"> | ||
</div> | ||
<kc-tooltip>{{:: 'identity-provider.base-url.tooltip' | translate}}</kc-tooltip> | ||
</div> | ||
<div class="form-group clearfix block"> | ||
<label class="col-md-2 control-label" for="apiUrl">{{:: 'identity-provider.api-url' | translate}}</label> | ||
<div class="col-md-6"> | ||
<input class="form-control" id="apiUrl" type="text" ng-model="identityProvider.config.apiUrl"> | ||
</div> | ||
<kc-tooltip>{{:: 'identity-provider.api-url.tooltip' | translate}}</kc-tooltip> | ||
</div> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.