Skip to content

Commit

Permalink
Features/keycloak 22 support (#25)
Browse files Browse the repository at this point in the history
* Updated to Keycloak v22 + update version to 1.1.0
* Typo & Lint
  • Loading branch information
stephane-segning authored Aug 2, 2023
1 parent d492274 commit faa394f
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
prerelease: false
allowUpdates: true
bodyFile: CHANGELOG.md
tag: v1.0.0
tag: v1.1.0
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# CHANGELOG

- Upgrade Keycloak to version 21
- Added CI builds
- Upgrade to Java 17
- Used native client for api calls
- Extended base login
- Upgrade Keycloak to version 22
4 changes: 2 additions & 2 deletions Dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG TAG=21.0.1
ARG TAG=22.0.1

FROM quay.io/keycloak/keycloak:${TAG}

ENV PHONENUMBER_LOGIN_PLUGIN_VERSION 1.0.0
ENV PHONENUMBER_LOGIN_PLUGIN_VERSION 1.1.0

ENV KEYCLOAK_DIR /opt/keycloak
ENV KC_PROXY edge
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG TAG=21.0.1
ARG TAG=22.0.1

FROM quay.io/keycloak/keycloak:${TAG}

ENV PHONENUMBER_LOGIN_PLUGIN_VERSION 1.0.0
ENV PHONENUMBER_LOGIN_PLUGIN_VERSION 1.1.0
ENV KEYCLOAK_DIR /opt/keycloak
ENV KC_PROXY edge

Expand Down
2 changes: 1 addition & 1 deletion openapi/sms-open-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
email: dev@ssegning.com
license:
name: MIT
version: 1.0.0
version: 1.1.0
externalDocs:
description: Find out more about calling setting up an external service to verify phone number
url: https://blog.ssegning.com
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>com.vymalo.keycloak</groupId>
<artifactId>keycloak-phonenumber-login</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>

<properties>
<java.version>17</java.version>
<lombock.version>1.18.26</lombock.version>
<keycloak.version>21.0.1</keycloak.version>
<keycloak.version>22.0.1</keycloak.version>
<googlecode.libphonenumber.version>8.13.8</googlecode.libphonenumber.version>
<googlecode.geocoder.version>2.202</googlecode.geocoder.version>
<swagger-annotations-version>1.6.9</swagger-annotations-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PhoneNumberChooseUser implements
private static final Map<String, String> infos = new HashMap<>();

static {
infos.put("version", "1.0.0");
infos.put("version", "1.1.0");

final var property = new ProviderConfigProperty();
property.setName(ConfigKey.USER_PHONE_ATTRIBUTE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.google.i18n.phonenumbers.NumberParseException;
import com.vymalo.keycloak.constants.PhoneKey;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import lombok.NoArgsConstructor;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.Config;
Expand All @@ -13,8 +15,6 @@
import org.keycloak.provider.ServerInfoAwareProviderFactory;
import org.keycloak.sessions.AuthenticationSessionModel;

import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -36,11 +36,11 @@ public class PhoneNumberConfirmNumber implements
public static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.REQUIRED
};
private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>();
private static final List<ProviderConfigProperty> configProperties = new ArrayList<>();
private static final Map<String, String> infos = new HashMap<>();

static {
infos.put("version", "1.0.0");
infos.put("version", "1.1.0");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.vymalo.keycloak.constants.PhoneNumberHelper;
import com.vymalo.keycloak.constants.Utils;
import com.vymalo.keycloak.model.CountryPhoneCode;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import lombok.NoArgsConstructor;
import lombok.extern.jbosslog.JBossLog;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -21,8 +23,6 @@
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ServerInfoAwareProviderFactory;

import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -43,11 +43,11 @@ public class PhoneNumberGetNumber implements
AuthenticationExecutionModel.Requirement.REQUIRED
};

private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>();
private static final List<ProviderConfigProperty> configProperties = new ArrayList<>();
private static final Map<String, String> infos = new HashMap<>();

static {
infos.put("version", "1.0.0");
infos.put("version", "1.1.0");

ProviderConfigProperty property;

Expand All @@ -63,7 +63,7 @@ public class PhoneNumberGetNumber implements
private static boolean handlePreExistingUser(AuthenticationFlowContext context, UserModel existingUser) {
String attrName = Utils.getConfigString(context.getAuthenticatorConfig(), ConfigKey.USER_PHONE_ATTRIBUTE_NAME, PhoneNumberHelper.DEFAULT_PHONE_KEY_NAME);
final var phoneNumbers = existingUser.getAttributeStream(attrName).toList();
if (phoneNumbers.size() >= 1) {
if (!phoneNumbers.isEmpty()) {
String phoneNumber = phoneNumbers.get(0);

log.debugf("Forget-password triggered when re-authenticating user after first broker login. Pre-filling request-user-phone-number screen with user's phone '%s' ", phoneNumber);
Expand Down Expand Up @@ -138,7 +138,6 @@ public void action(AuthenticationFlowContext context) {
try {
number = PhoneNumberHelper.phoneNumberUtil.parse(phoneNumber, null);
} catch (NumberParseException e) {
e.printStackTrace();
event.clone()
.detail("phone_number", phoneNumber)
.error("parse number error: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public class PhoneNumberSendTan implements
AuthenticationExecutionModel.Requirement.REQUIRED
};
private static final Logger LOG = Logger.getLogger(PhoneNumberSendTan.class);
private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>();
private static final List<ProviderConfigProperty> configProperties = new ArrayList<>();
private static final Map<String, String> infos = new HashMap<>();

static {
infos.put("version", "1.0.0");
infos.put("version", "1.1.0");

ProviderConfigProperty property;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PhoneNumberUpdateUser implements
private static final Map<String, String> infos = new HashMap<>();

static {
infos.put("version", "1.0.0");
infos.put("version", "1.1.0");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.keycloak.provider.ServerInfoAwareProviderFactory;
import org.keycloak.sessions.AuthenticationSessionModel;

import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import java.util.*;

@JBossLog
Expand All @@ -30,11 +30,11 @@ public class PhoneNumberValidateTan implements
public static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.REQUIRED
};
private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>();
private static final List<ProviderConfigProperty> configProperties = new ArrayList<>();
private static final Map<String, String> infos = new HashMap<>();

static {
infos.put("version", "1.0.0");
infos.put("version", "1.1.0");
}

@Override
Expand Down

0 comments on commit faa394f

Please sign in to comment.