Skip to content
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

feat: Users management. #155

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Integration Tests

on:
workflow_dispatch:

jobs:
integration_tets:
runs-on: ubuntu-22.04

environment: cstar-d-mcshared

permissions:
id-token: write # Get OIDC token to authenticate to Azure.

steps:
#
# Checkout the source code.
#
- name: Checkout the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2

#
# Setup Java Build Environment.
#
- name: Setup Java Build Environment
uses: pagopa/mil-actions/setup-java-build-env@f782a1b3cdb79afda2c10007ae46b831b31fe640 # 1.1.2
with:
gh_user: ${{ secrets.GIT_USER }}
gh_token: ${{ secrets.GIT_PAT }}

#
# Run integration tests.
#
- name: Run integration tests
run: |
${{ runner.temp }}/maven/bin/mvn verify \
-DskipUTs=true \
-DskipITs=false \
-Dbase_uri=${{ secrets.IT_BASE_URI }}
-Dadmin_client_id=${{ secrets.IT_ADMIN_CLIENT_ID }} \
-Dadmin_client_secret=${{ secrets.IT_ADMIN_CLIENT_SECRET }} \
-Dtoken_info_client_id=${{ secrets.IT_TOKEN_INFO_CLIENT_ID }} \
-Dtoken_info_client_secret=${{ secrets.IT_TOKEN_INFO_CLIENT_SECRET }} \
-Dtest_username=${{ secrets.IT_TEST_USERNAME }} \
-Dtest_password=${{ secrets.IT_TEST_PASSWORD }}
2 changes: 2 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
if: steps.semantic.outputs.new_release_published == 'true'
run: |
yq -i ".info.version = \"${{ steps.semantic.outputs.new_release_version }}-RC\"" "src/main/resources/META-INF/openapi.yaml"
yq -i ".info.version = \"${{ steps.semantic.outputs.new_release_version }}-RC\"" "src/main/resources/META-INF/openapi_not_admin.yaml"
${{ runner.temp }}/maven/bin/mvn versions:set -DnewVersion=${{ steps.semantic.outputs.new_release_version }}-RC -s ${{ runner.temp }}/settings.xml --no-transfer-progress

#
Expand Down Expand Up @@ -142,6 +143,7 @@ jobs:
run: |
${{ runner.temp }}/maven/bin/mvn versions:set -DnewVersion=${{ steps.semantic.outputs.new_release_version }} -s ${{ runner.temp }}/settings.xml --no-transfer-progress
yq -i ".info.version = \"${{ steps.semantic.outputs.new_release_version }}\"" "src/main/resources/META-INF/openapi.yaml"
yq -i ".info.version = \"${{ steps.semantic.outputs.new_release_version }}\"" "src/main/resources/META-INF/openapi_not_admin.yaml"
git config user.name "GitHub Workflow"
git config user.email "<>"
git add pom.xml
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<sonar.issue.ignore.multicriteria.e2.ruleKey>java:S117</sonar.issue.ignore.multicriteria.e2.ruleKey>
<sonar.issue.ignore.multicriteria.e2.resourceKey>src/test/java/**/*.java</sonar.issue.ignore.multicriteria.e2.resourceKey>
<skipITs>true</skipITs>
<skipUTs>false</skipUTs>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -268,6 +269,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<skipTests>${skipUTs}</skipTests>
<systemPropertyVariables>
<java.util.logging.manager>
org.jboss.logmanager.LogManager</java.util.logging.manager>
Expand Down Expand Up @@ -356,6 +358,7 @@
</limits>
</rule>
</rules>
<skip>${skipUTs}</skip>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class AuthErrorCode {
public static final String REFRESH_TOKEN_MUST_MATCH_REGEXP = MODULE_ID + "000008";
public static final String ERROR_SEARCHING_FOR_CLIENT = MODULE_ID + "000009";
public static final String CLIENT_NOT_FOUND = MODULE_ID + "00000A";
public static final String ERROR_SEARCHING_FOR_CREDENTIALS = MODULE_ID + "00000B";
public static final String ERROR_SEARCHING_FOR_USER = MODULE_ID + "00000B";
public static final String WRONG_CREDENTIALS = MODULE_ID + "00000C";
public static final String ERROR_VERIFING_CREDENTIALS = MODULE_ID + "00000D";
public static final String INCONSISTENT_CREDENTIALS = MODULE_ID + "00000E";
Expand Down Expand Up @@ -55,7 +55,7 @@ public final class AuthErrorCode {
public static final String ERROR_ENCRYPTING_CLAIM = MODULE_ID + "000027";
public static final String ERROR_DECRYPTING_CLAIM = MODULE_ID + "000028";
public static final String ERROR_SIGNING_TOKEN = MODULE_ID + "000029";
public static final String ERROR_SEARCHING_FOR_USER = MODULE_ID + "00002A";
public static final String USER_NOT_FOUND = MODULE_ID + "00002A";
// @formatter:on

public static final String MUST_NOT_BE_NULL_MSG = " must not be null";
Expand All @@ -64,7 +64,7 @@ public final class AuthErrorCode {
// @formatter:off
public static final String GRANT_TYPE_MUST_NOT_BE_NULL_MSG = "[" + GRANT_TYPE_MUST_NOT_BE_NULL + "] Grant type" + MUST_NOT_BE_NULL_MSG;
public static final String GRANT_TYPE_MUST_MATCH_REGEXP_MSG = "[" + GRANT_TYPE_MUST_MATCH_REGEXP + "] Grant type" + MUST_MATCH_REGEXP_MSG;
public static final String USERNAME_MUST_MATCH_REGEXP_MSG = "[" + USERNAME_MUST_MATCH_REGEXP + "] User name" + MUST_MATCH_REGEXP_MSG;
public static final String USERNAME_MUST_MATCH_REGEXP_MSG = "[" + USERNAME_MUST_MATCH_REGEXP + "] Username" + MUST_MATCH_REGEXP_MSG;
public static final String PASSWORD_MUST_MATCH_REGEXP_MSG = "[" + PASSWORD_MUST_MATCH_REGEXP + "] Password" + MUST_MATCH_REGEXP_MSG;
public static final String REFRESH_TOKEN_MUST_MATCH_REGEXP_MSG = "[" + REFRESH_TOKEN_MUST_MATCH_REGEXP + "] Refresh token" + MUST_MATCH_REGEXP_MSG;
public static final String EXT_TOKEN_MUST_MATCH_REGEXP_MSG = "[" + EXT_TOKEN_MUST_MATCH_REGEXP + "] Ext token" + MUST_MATCH_REGEXP_MSG;
Expand All @@ -74,9 +74,10 @@ public final class AuthErrorCode {
public static final String SCOPE_MUST_MATCH_REGEXP_MSG = "[" + SCOPE_MUST_MATCH_REGEXP + "] Scope" + MUST_MATCH_REGEXP_MSG;
public static final String CLIENT_SECRET_MUST_MATCH_REGEXP_MSG = "[" + CLIENT_SECRET_MUST_MATCH_REGEXP + "] Client secret" + MUST_MATCH_REGEXP_MSG;
public static final String FISCAL_CODE_MUST_MATCH_REGEXP_MSG = "[" + FISCAL_CODE_MUST_MATCH_REGEXP + "] Fiscal code" + MUST_MATCH_REGEXP_MSG;
public static final String INCONSISTENT_REQUEST_MSG = "[" + INCONSISTENT_REQUEST + "] Inconsistent request.";
public static final String INCONSISTENT_REQUEST_MSG = "[" + INCONSISTENT_REQUEST + "] Inconsistent request";
public static final String TOKEN_MUST_NOT_BE_NULL_MSG = "[" + TOKEN_MUST_NOT_BE_NULL + "] Token" + MUST_NOT_BE_NULL_MSG;
public static final String TOKEN_MUST_MATCH_REGEXP_MSG = "[" + TOKEN_MUST_MATCH_REGEXP + "] Token" + MUST_MATCH_REGEXP_MSG;
public static final String USER_NOT_FOUND_MSG = "[" + USER_NOT_FOUND + "] User not found";
// @formatter:on

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public final class AdminErrorCode {
public static final String ROLE_MUST_NOT_BE_NULL = AuthErrorCode.MODULE_ID + "100018";
public static final String ROLES_MUST_NOT_BE_NULL = AuthErrorCode.MODULE_ID + "100019";
public static final String SET_OF_ROLES_ID_MUST_MATCH_REGEXP = AuthErrorCode.MODULE_ID + "10001A";
public static final String USERNAME_MUST_NOT_BE_NULL = AuthErrorCode.MODULE_ID + "10001B";
public static final String DUPLICATE_USER = AuthErrorCode.MODULE_ID + "10001C";
public static final String ERROR_STORING_USER = AuthErrorCode.MODULE_ID + "10001D";
public static final String ERROR_DELETING_USER = AuthErrorCode.MODULE_ID + "10001E";

public static final String MUST_BE_BETWEEN_MIN_AND_MAX_MSG = " must be between {min} and {max}";

Expand Down Expand Up @@ -71,7 +75,10 @@ public final class AdminErrorCode {
public static final String ROLE_MUST_MATCH_REGEXP_MSG = "[" + ROLE_MUST_MATCH_REGEXP + "] Role" + AuthErrorCode.MUST_MATCH_REGEXP_MSG;
public static final String ROLES_MUST_NOT_BE_NULL_MSG = "[" + ROLES_MUST_NOT_BE_NULL + "] Roles" + AuthErrorCode.MUST_NOT_BE_NULL_MSG;
public static final String SET_OF_ROLES_ID_MUST_MATCH_REGEXP_MSG = "[" + SET_OF_ROLES_ID_MUST_MATCH_REGEXP + "] Set of roles" + AuthErrorCode.MUST_MATCH_REGEXP_MSG;

public static final String USERNAME_MUST_NOT_BE_NULL_MSG = "[" + USERNAME_MUST_NOT_BE_NULL + "] Username" + AuthErrorCode.MUST_NOT_BE_NULL_MSG;
public static final String DUPLICATE_USER_MSG = "[" + DUPLICATE_USER + "] Duplicate user";
public static final String ERROR_STORING_USER_MSG = "[" + ERROR_STORING_USER + "] Error storing user";
public static final String ERROR_DELETING_USER_MSG = "[" + ERROR_DELETING_USER + "] Error deleting user";
// @formatter:on

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ public class AdminJsonPropertyName {
*/
public static final String SET_OF_ROLES_ID = "id";

/**
* <p>
* Username.
* </p>
*/
public static final String USERNAME = "username";

/**
* <p>
* Password.
* </p>
*/
public static final String PASSWORD = "password";

/**
* <p>
* This class contains constants only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public class AdminQueryParamName {
*/
public static final String CLIENT_ID = "clientId";

/**
* <p>
* User name.
* </p>
*/
public static final String USERNAME = "username";

/**
* <p>
* This class contains only constants.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class CreateOrUpdateClientRequest {
* </p>
*/
@JsonProperty(value = AdminJsonPropertyName.DESCRIPTION)
@NotNull(message = AdminErrorCode.DESCRIPTION_MUST_MATCH_REGEXP_MSG)
@NotNull(message = AdminErrorCode.DESCRIPTION_MUST_NOT_BE_NULL_MSG)
@Pattern(regexp = AdminValidationPattern.DESCRIPTION, message = AdminErrorCode.DESCRIPTION_MUST_MATCH_REGEXP_MSG)
private String description;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* CreateUserRequest.java
*
* 20 nov 2024
*/
package it.pagopa.swclient.mil.auth.admin.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

import io.quarkus.runtime.annotations.RegisterForReflection;
import it.pagopa.swclient.mil.ErrorCode;
import it.pagopa.swclient.mil.auth.AuthErrorCode;
import it.pagopa.swclient.mil.auth.admin.AdminErrorCode;
import it.pagopa.swclient.mil.auth.bean.AuthValidationPattern;
import it.pagopa.swclient.mil.bean.ValidationPattern;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
*
* @author Antonio Tarricone
*/
@RegisterForReflection
@JsonInclude(Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
@Data
@Accessors(chain = true)
public class CreateUserRequest {
/**
* <p>
* User name.
* </p>
*/
@JsonProperty(value = AdminJsonPropertyName.USERNAME)
@NotNull(message = AdminErrorCode.USERNAME_MUST_NOT_BE_NULL_MSG)
@Pattern(regexp = AuthValidationPattern.USERNAME, message = AuthErrorCode.USERNAME_MUST_MATCH_REGEXP_MSG)
@ToString.Exclude
private String username;

/**
* <p>
* Channel.
* </p>
*/
@JsonProperty(value = AdminJsonPropertyName.CHANNEL)
@Pattern(regexp = ValidationPattern.CHANNEL, message = ErrorCode.CHANNEL_MUST_MATCH_REGEXP_MSG)
private String channel;

/**
* <p>
* Acquirer ID.
* </p>
*/
@JsonProperty(value = AdminJsonPropertyName.ACQUIRER_ID)
@Pattern(regexp = ValidationPattern.ACQUIRER_ID, message = ErrorCode.ACQUIRER_ID_MUST_MATCH_REGEXP_MSG)
private String acquirerId;

/**
* <p>
* Merchant ID.
* </p>
*/
@JsonProperty(value = AdminJsonPropertyName.MERCHANT_ID)
@Pattern(regexp = ValidationPattern.MERCHANT_ID, message = ErrorCode.MERCHANT_ID_MUST_MATCH_REGEXP_MSG)
private String merchantId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* CreateUserResponse.java
*
* 21 nov 2024
*/
package it.pagopa.swclient.mil.auth.admin.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
*
* @author Antonio Tarricone
*/
@RegisterForReflection
@JsonInclude(Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
@Data
@Accessors(chain = true)
public class CreateUserResponse {
/**
* <p>
* Password.
* </p>
*/
@JsonProperty(AdminJsonPropertyName.PASSWORD)
@ToString.Exclude
private String password;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class ClientResource {
*/
@ConfigProperty(name = "base-url", defaultValue = "")
String baseUrl;

/*
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class RolesResource {
*/
@ConfigProperty(name = "base-url", defaultValue = "")
String baseUrl;

/**
* <p>
* Repository of roles entities.
Expand Down
Loading
Loading