Skip to content

Commit

Permalink
Make OIDCInfoProvider like singleton
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
  • Loading branch information
AndrienkoAleksandr committed Dec 16, 2020
1 parent 798b475 commit 07b109d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
public class OIDCInfoProvider implements Provider<OIDCInfo> {

private static final Logger LOG = LoggerFactory.getLogger(OIDCInfoProvider.class);
private OIDCInfo oidcInfo;

@Inject
@Nullable
Expand All @@ -63,10 +62,6 @@ public class OIDCInfoProvider implements Provider<OIDCInfo> {
/** @return OIDCInfo with OIDC settings information. */
@Override
public OIDCInfo get() {
if (oidcInfo != null) {
return oidcInfo;
}

this.validate();

String serverAuthUrl = (serverInternalURL != null) ? serverInternalURL : serverURL;
Expand All @@ -90,22 +85,20 @@ public OIDCInfo get() {
String jwksUri = setInternalUrl(jwksPublicUri);
String userInfoEndpoint = setInternalUrl(userInfoPublicEndpoint);

oidcInfo =
new OIDCInfo(
tokenPublicEndPoint,
endSessionPublicEndpoint,
userInfoPublicEndpoint,
userInfoEndpoint,
jwksPublicUri,
jwksUri,
serverAuthUrl);
return new OIDCInfo(
tokenPublicEndPoint,
endSessionPublicEndpoint,
userInfoPublicEndpoint,
userInfoEndpoint,
jwksPublicUri,
jwksUri,
serverAuthUrl);
} catch (IOException e) {
throw new RuntimeException(
"Exception while retrieving OpenId configuration from endpoint: " + wellKnownEndpoint, e);
} finally {
ProxyAuthenticator.resetAuthenticator();
}
return this.oidcInfo;
}

private String getWellKnownEndpoint(String serverAuthUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void configure() {
bind(ProfileDao.class).to(KeycloakProfileDao.class);
bind(JwkProvider.class).toProvider(KeycloakJwkProvider.class);
bind(JwtParser.class).toProvider(KeycloakJwtParserProvider.class);
bind(OIDCInfo.class).toProvider(OIDCInfoProvider.class);
bind(OIDCInfo.class).toProvider(OIDCInfoProvider.class).asEagerSingleton();
bind(PersonalAccountUserManager.class).to(KeycloakUserManager.class);

bind(OAuthAPI.class).toProvider(OAuthAPIProvider.class);
Expand Down
16 changes: 16 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

mvn fmt:format
mvn sortpom:sort
mvn clean install -DskipTests=true

pushd dockerfiles/che || true

./build.sh --tag:nightly

popd || true

docker tag quay.io/eclipse/che-server:nightly quay.io/aandriienko/che-server:nightly

docker push quay.io/aandriienko/che-server:nightly
# chectl server:deploy -n eclipse-che -p minishift -n eclipse-che --installer=operator --cheimage=quay.io/aandriienko/che-server:nightly

0 comments on commit 07b109d

Please sign in to comment.