Merge pull request #411 from stianst/master
Twitter fix and read keycloak-sever.json from standalone/configuration
This commit is contained in:
commit
64a36aee03
8 changed files with 38 additions and 13 deletions
|
@ -38,6 +38,13 @@
|
||||||
<exclude>keycloak-ds.xml</exclude>
|
<exclude>keycloak-ds.xml</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.build.directory}/unpacked/deployments/auth-server.war/WEB-INF/classes/META-INF</directory>
|
||||||
|
<outputDirectory>keycloak/standalone/configuration</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>keycloak-server.json</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>${project.build.directory}/unpacked/themes</directory>
|
<directory>${project.build.directory}/unpacked/themes</directory>
|
||||||
<outputDirectory>keycloak/standalone/configuration/themes</outputDirectory>
|
<outputDirectory>keycloak/standalone/configuration/themes</outputDirectory>
|
||||||
|
|
|
@ -19,5 +19,12 @@
|
||||||
</includes>
|
</includes>
|
||||||
<outputDirectory>deployments</outputDirectory>
|
<outputDirectory>deployments</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.build.directory}/unpacked/deployments/auth-server.war/WEB-INF/classes/META-INF</directory>
|
||||||
|
<outputDirectory>configuration</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>keycloak-server.json</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
</assembly>
|
</assembly>
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
<para>
|
<para>
|
||||||
Twitter doesn't allow <literal>localhost</literal> in the redirect URI. To test on a local server
|
Twitter doesn't allow <literal>localhost</literal> in the redirect URI. To test on a local server
|
||||||
replace <literal>localhost</literal> with <literal>127.0.0.1</literal>.
|
replace <literal>localhost</literal> with <literal>127.0.0.1</literal>.
|
||||||
Twitter also restricts connection to TLS/SSL connections only, so you are required to use HTTPS to access
|
|
||||||
Keycloak to enable log in with Twitter.
|
|
||||||
</para>
|
</para>
|
||||||
</tip>
|
</tip>
|
||||||
</section>
|
</section>
|
|
@ -186,6 +186,10 @@ ol#kc-totp-settings li:first-of-type {
|
||||||
width: 125px;
|
width: 125px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.zocial:hover {
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
.zocial.facebook,
|
.zocial.facebook,
|
||||||
.zocial.github,
|
.zocial.github,
|
||||||
.zocial.google,
|
.zocial.google,
|
||||||
|
|
|
@ -33,7 +33,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
|
||||||
ProviderFactory factory = loadProviderFactory(spi, provider);
|
ProviderFactory factory = loadProviderFactory(spi, provider);
|
||||||
Config.Scope scope = Config.scope(spi.getName(), provider);
|
Config.Scope scope = Config.scope(spi.getName(), provider);
|
||||||
factory.init(scope);
|
factory.init(scope);
|
||||||
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
|
|
||||||
|
|
||||||
factories.put(factory.getId(), factory);
|
factories.put(factory.getId(), factory);
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
|
||||||
for (ProviderFactory factory : ServiceLoader.load(spi.getProviderFactoryClass())) {
|
for (ProviderFactory factory : ServiceLoader.load(spi.getProviderFactoryClass())) {
|
||||||
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
||||||
factory.init(scope);
|
factory.init(scope);
|
||||||
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
|
|
||||||
|
|
||||||
factories.put(factory.getId(), factory);
|
factories.put(factory.getId(), factory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,19 @@ public class KeycloakApplication extends Application {
|
||||||
|
|
||||||
protected void loadConfig() {
|
protected void loadConfig() {
|
||||||
try {
|
try {
|
||||||
URL config = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json");
|
URL config = null;
|
||||||
|
|
||||||
|
String configDir = System.getProperty("jboss.server.config.dir");
|
||||||
|
if (configDir != null) {
|
||||||
|
File f = new File(configDir + File.separator + "keycloak-server.json");
|
||||||
|
if (f.isFile()) {
|
||||||
|
config = f.toURI().toURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
config = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json");
|
||||||
|
}
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
JsonNode node = new ObjectMapper().readTree(config);
|
JsonNode node = new ObjectMapper().readTree(config);
|
||||||
|
@ -116,6 +128,8 @@ public class KeycloakApplication extends Application {
|
||||||
|
|
||||||
log.info("Loaded config from " + config);
|
log.info("Loaded config from " + config);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
log.warn("Config 'keycloak-server.json' not found");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to load config", e);
|
throw new RuntimeException("Failed to load config", e);
|
||||||
|
|
|
@ -74,11 +74,11 @@ public class JsonConfigProvider implements Config.ConfigProvider {
|
||||||
if (n == null) {
|
if (n == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (n.isArray()) {
|
} else if (n.isArray()) {
|
||||||
ArrayList<String> l = new ArrayList<String>();
|
String[] a = new String[n.size()];
|
||||||
for (JsonNode e : n) {
|
for (int i = 0; i < a.length; i++) {
|
||||||
l.add(StringPropertyReplacer.replaceProperties(e.getTextValue()));
|
a[i] = StringPropertyReplacer.replaceProperties(n.get(i).getTextValue());
|
||||||
}
|
}
|
||||||
return (String[]) l.toArray();
|
return a;
|
||||||
} else {
|
} else {
|
||||||
return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) };
|
return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) };
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,7 @@ public class TwitterProvider implements SocialProvider {
|
||||||
Twitter twitter = new TwitterFactory().getInstance();
|
Twitter twitter = new TwitterFactory().getInstance();
|
||||||
twitter.setOAuthConsumer(config.getKey(), config.getSecret());
|
twitter.setOAuthConsumer(config.getKey(), config.getSecret());
|
||||||
|
|
||||||
String redirectUri = config.getCallbackUrl();
|
RequestToken requestToken = twitter.getOAuthRequestToken(config.getCallbackUrl());
|
||||||
redirectUri = redirectUri.replace("//localhost", "//127.0.0.1");
|
|
||||||
|
|
||||||
RequestToken requestToken = twitter.getOAuthRequestToken(redirectUri);
|
|
||||||
|
|
||||||
return AuthRequest.create(requestToken.getToken(), requestToken.getAuthenticationURL())
|
return AuthRequest.create(requestToken.getToken(), requestToken.getAuthenticationURL())
|
||||||
.setAttribute("token", requestToken.getToken()).setAttribute("tokenSecret", requestToken.getTokenSecret())
|
.setAttribute("token", requestToken.getToken()).setAttribute("tokenSecret", requestToken.getTokenSecret())
|
||||||
|
|
Loading…
Reference in a new issue