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>
|
||||
</excludes>
|
||||
</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>
|
||||
<directory>${project.build.directory}/unpacked/themes</directory>
|
||||
<outputDirectory>keycloak/standalone/configuration/themes</outputDirectory>
|
||||
|
|
|
@ -19,5 +19,12 @@
|
|||
</includes>
|
||||
<outputDirectory>deployments</outputDirectory>
|
||||
</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>
|
||||
</assembly>
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
<para>
|
||||
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>.
|
||||
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>
|
||||
</tip>
|
||||
</section>
|
|
@ -186,6 +186,10 @@ ol#kc-totp-settings li:first-of-type {
|
|||
width: 125px;
|
||||
}
|
||||
|
||||
.zocial:hover {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.zocial.facebook,
|
||||
.zocial.github,
|
||||
.zocial.google,
|
||||
|
|
|
@ -33,7 +33,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
|
|||
ProviderFactory factory = loadProviderFactory(spi, provider);
|
||||
Config.Scope scope = Config.scope(spi.getName(), provider);
|
||||
factory.init(scope);
|
||||
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
|
||||
|
||||
factories.put(factory.getId(), factory);
|
||||
|
||||
|
@ -42,7 +41,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
|
|||
for (ProviderFactory factory : ServiceLoader.load(spi.getProviderFactoryClass())) {
|
||||
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
||||
factory.init(scope);
|
||||
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
|
||||
|
||||
factories.put(factory.getId(), factory);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,19 @@ public class KeycloakApplication extends Application {
|
|||
|
||||
protected void loadConfig() {
|
||||
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) {
|
||||
JsonNode node = new ObjectMapper().readTree(config);
|
||||
|
@ -116,6 +128,8 @@ public class KeycloakApplication extends Application {
|
|||
|
||||
log.info("Loaded config from " + config);
|
||||
return;
|
||||
} else {
|
||||
log.warn("Config 'keycloak-server.json' not found");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to load config", e);
|
||||
|
|
|
@ -74,11 +74,11 @@ public class JsonConfigProvider implements Config.ConfigProvider {
|
|||
if (n == null) {
|
||||
return null;
|
||||
} else if (n.isArray()) {
|
||||
ArrayList<String> l = new ArrayList<String>();
|
||||
for (JsonNode e : n) {
|
||||
l.add(StringPropertyReplacer.replaceProperties(e.getTextValue()));
|
||||
String[] a = new String[n.size()];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = StringPropertyReplacer.replaceProperties(n.get(i).getTextValue());
|
||||
}
|
||||
return (String[]) l.toArray();
|
||||
return a;
|
||||
} else {
|
||||
return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) };
|
||||
}
|
||||
|
|
|
@ -48,10 +48,7 @@ public class TwitterProvider implements SocialProvider {
|
|||
Twitter twitter = new TwitterFactory().getInstance();
|
||||
twitter.setOAuthConsumer(config.getKey(), config.getSecret());
|
||||
|
||||
String redirectUri = config.getCallbackUrl();
|
||||
redirectUri = redirectUri.replace("//localhost", "//127.0.0.1");
|
||||
|
||||
RequestToken requestToken = twitter.getOAuthRequestToken(redirectUri);
|
||||
RequestToken requestToken = twitter.getOAuthRequestToken(config.getCallbackUrl());
|
||||
|
||||
return AuthRequest.create(requestToken.getToken(), requestToken.getAuthenticationURL())
|
||||
.setAttribute("token", requestToken.getToken()).setAttribute("tokenSecret", requestToken.getTokenSecret())
|
||||
|
|
Loading…
Reference in a new issue