-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1723 from reportportal/rc/5.9.0
Release 5.9.0
- Loading branch information
Showing
32 changed files
with
1,223 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
FROM alpine:latest | ||
LABEL version=5.8.0 description="EPAM Report portal. Main API Service" maintainer="Andrei Varabyeu <[email protected]>, Hleb Kanonik <[email protected]>" | ||
FROM amazoncorretto:11.0.17 | ||
LABEL version=5.9.0 description="EPAM Report portal. Main API Service" maintainer="Andrei Varabyeu <[email protected]>, Hleb Kanonik <[email protected]>" | ||
ARG GH_TOKEN | ||
RUN echo 'exec java ${JAVA_OPTS} -jar service-api-5.8.0-exec.jar' > /start.sh && chmod +x /start.sh && \ | ||
wget --header="Authorization: Bearer ${GH_TOKEN}" -q https://maven.pkg.github.com/reportportal/service-api/com/epam/reportportal/service-api/5.8.0/service-api-5.8.0-exec.jar | ||
RUN echo 'exec java ${JAVA_OPTS} -jar service-api-5.9.0-exec.jar' > /start.sh && chmod +x /start.sh && \ | ||
wget --header="Authorization: Bearer ${GH_TOKEN}" -q https://maven.pkg.github.com/reportportal/service-api/com/epam/reportportal/service-api/5.9.0/service-api-5.9.0-exec.jar | ||
ENV JAVA_OPTS="-Xmx1g -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=70 -Djava.security.egd=file:/dev/./urandom" | ||
VOLUME ["/tmp"] | ||
EXPOSE 8080 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pipeline { | ||
agent any | ||
|
||
environment { | ||
JAVA_HOME = "${tool 'openjdk-11'}" | ||
PATH = "${env.JAVA_HOME}/bin:${env.PATH}" | ||
DOCKERHUB = credentials('dockerhub') | ||
GITHUB = credentials('github_token') | ||
} | ||
|
||
stages { | ||
stage('Assemble') { | ||
steps { | ||
sh './gradlew clean assemble -P buildNumber=$VERSION' | ||
} | ||
} | ||
|
||
stage('Test') { | ||
steps { | ||
sh './gradlew test --full-stacktrace' | ||
} | ||
} | ||
|
||
stage('Build Artifact'){ | ||
steps{ | ||
sh './gradlew build -PreleaseMode=true -PgithubUserName=$GITHUB_USR -PgithubToken=$GITHUB_PSW -Pscripts.version=master -Pmigrations.version=master -Pbom.version=$VERSION' | ||
} | ||
} | ||
|
||
stage('Build Docker Image'){ | ||
steps{ | ||
sh './gradlew buildDocker -P dockerTag=reportportal/service-api:$VERSION' | ||
} | ||
} | ||
|
||
stage('Push to DockerHub') { | ||
steps { | ||
sh 'echo $DOCKERHUB_PSW | docker login -u $DOCKERHUB_USR --password-stdin && docker push reportportal/service-api:$VERSION' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/com/epam/ta/reportportal/auth/ApiKeyUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2023 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.epam.ta.reportportal.auth; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Arrays; | ||
import java.util.Base64; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import org.apache.commons.codec.digest.DigestUtils; | ||
|
||
public class ApiKeyUtils { | ||
|
||
private static final String UUID_PATTERN = | ||
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"; | ||
|
||
private ApiKeyUtils() { | ||
} | ||
|
||
/** | ||
* Validate token sign | ||
*/ | ||
public static boolean validateToken(String apiKey) { | ||
if (isUUID(apiKey) || (apiKey.length() == 27 && Base64.getUrlDecoder().decode(apiKey.getBytes( | ||
StandardCharsets.US_ASCII)).length == 20)) { | ||
return true; | ||
} | ||
String[] nameChecksum = apiKey.split("_", 2); | ||
try { | ||
byte[] checksumBytes = Base64.getUrlDecoder().decode(nameChecksum[1]); | ||
byte[] actualUuid = Arrays.copyOf(checksumBytes, 16); | ||
byte[] actualHash = Arrays.copyOfRange(checksumBytes, 16, checksumBytes.length); | ||
|
||
byte[] nameBytes = nameChecksum[0].getBytes(StandardCharsets.UTF_8); | ||
ByteBuffer nameUuidBb = ByteBuffer.wrap(new byte[nameBytes.length + actualUuid.length]); | ||
nameUuidBb.put(nameBytes); | ||
nameUuidBb.put(actualUuid); | ||
|
||
byte[] expected = DigestUtils.sha3_256(nameUuidBb.array()); | ||
return Arrays.equals(actualHash, expected); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
private static boolean isUUID(String uuidStr) { | ||
Pattern pattern = Pattern.compile(UUID_PATTERN); | ||
Matcher matcher = pattern.matcher(uuidStr); | ||
return matcher.matches(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.