Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
63 changes: 35 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ buildscript {
plugins {
alias libs.plugins.nexus.publish
alias libs.plugins.osdetector apply false
alias libs.plugins.kotlin apply false
alias libs.plugins.ktlint apply false
alias libs.plugins.jib apply false
}

allprojects {
Expand Down Expand Up @@ -78,28 +81,11 @@ configure(projectsWithFlags('java')) {
compileOnly libs.jetty.alpn.api

// Logging
if (project.name.startsWith("java-spring-boot3")) {
implementation libs.slf4j2.api
testImplementation libs.slf4j2.jul.to.slf4j
testImplementation libs.slf4j2.jcl.over.slf4j
testImplementation libs.slf4j2.log4j.over.slf4j
testRuntimeOnly libs.logback15
configurations.configureEach {
resolutionStrategy {
force libs.slf4j2.api.get()
force libs.slf4j2.jul.to.slf4j.get()
force libs.slf4j2.jcl.over.slf4j.get()
force libs.slf4j2.log4j.over.slf4j.get()
force libs.logback15.get()
}
}
} else {
implementation libs.slf4j1.api
testImplementation libs.slf4j1.jul.to.slf4j
testImplementation libs.slf4j1.jcl.over.slf4j
testImplementation libs.slf4j1.log4j.over.slf4j
testRuntimeOnly libs.logback12
}
implementation libs.slf4j1.api
testImplementation libs.slf4j1.jul.to.slf4j
testImplementation libs.slf4j1.jcl.over.slf4j
testImplementation libs.slf4j1.log4j.over.slf4j
testRuntimeOnly libs.logback12
Comment on lines -81 to +88

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make separated concern for other configurations.
I had some dependency issues by this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which problem you've gone through but make sure not to include the slf4j1 for spring boot3 module.


// Test-time dependencies
testImplementation libs.json.unit.fluent
Expand All @@ -115,12 +101,9 @@ configure(projectsWithFlags('java')) {
testRuntimeOnly libs.junit5.vintage.engine
}

// Target Java 8 except for spring-boot3
if (!project.name.startsWith("java-spring-boot3")) {
tasks.withType(JavaCompile) {
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
options.release = 8
}
tasks.withType(JavaCompile) {
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
options.release = 8
}
}

Expand Down Expand Up @@ -218,6 +201,30 @@ class TestsReportTask extends DefaultTask {
}
}

configure(projectsWithFlags('spring-boot3')) {

tasks.withType(JavaCompile) {
options.release = 17
}

dependencies {
implementation libs.slf4j2.api
testImplementation libs.slf4j2.jul.to.slf4j
testImplementation libs.slf4j2.jcl.over.slf4j
testImplementation libs.slf4j2.log4j.over.slf4j
testRuntimeOnly libs.logback15
configurations.configureEach {
resolutionStrategy {
force libs.slf4j2.api.get()
force libs.slf4j2.jul.to.slf4j.get()
force libs.slf4j2.jcl.over.slf4j.get()
force libs.slf4j2.log4j.over.slf4j.get()
force libs.logback15.get()
}
}
}
}

// Configure the Javadoc tasks of all projects.
allprojects {
tasks.withType(Javadoc) {
Expand Down
36 changes: 36 additions & 0 deletions cloud-native/boot-loader/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
plugins {
alias libs.plugins.spring.boot
alias libs.plugins.kotlin.spring
alias libs.plugins.jib
}

dependencies {
implementation libs.spring.boot3.starter.web
implementation libs.spring.boot3.starter.actuator
implementation libs.jackson.kotlin
implementation project(":server")
implementation project(":server-auth:saml")
implementation project(':server-mirror-git')

implementation(libs.armeria.saml) {
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
}

implementation 'org.opensaml:opensaml-security-impl:3.4.6'
implementation 'org.opensaml:opensaml-saml-impl:3.4.6'

testImplementation libs.spring.boot3.starter.test

testImplementation("com.willowtreeapps.assertk:assertk:0.28.1")
}

jib {
from {
image = 'eclipse-temurin:21-jre-jammy'
}

container {
creationTime = 'USE_CURRENT_TIMESTAMP'
ports = ['8080', '36462']
}
}
3 changes: 3 additions & 0 deletions cloud-native/boot-loader/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
javaSourceCompatibility=17
javaTargetCompatibility=17
minimumJavaVersion=17
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
* Copyright 2024 LINE Corporation
*
* LINE Corporation licenses this file to you 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:
*
* https://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.linecorp.armeria.server.saml;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.linecorp.armeria.server.saml.SamlPortConfig.validatePort;
import static java.util.Objects.requireNonNull;

import java.net.URI;
import java.net.URISyntaxException;

import org.springframework.web.util.UriComponentsBuilder;

import com.google.common.base.MoreObjects;

import com.linecorp.armeria.common.annotation.Nullable;
import com.linecorp.armeria.common.util.Exceptions;

/**
* A SAML service URL and its binding protocol.
*/
public final class SamlEndpoint {
/**
* Creates a {@link SamlEndpoint} of the specified {@code uri} and the HTTP Redirect binding protocol.
*/
public static SamlEndpoint ofHttpRedirect(String uri) {
requireNonNull(uri, "uri");
try {
return ofHttpRedirect(new URI(uri));
} catch (URISyntaxException e) {
return Exceptions.throwUnsafely(e);
}
}

/**
* Creates a {@link SamlEndpoint} of the specified {@code uri} and the HTTP Redirect binding protocol.
*/
public static SamlEndpoint ofHttpRedirect(URI uri) {
requireNonNull(uri, "uri");
return new SamlEndpoint(uri, SamlBindingProtocol.HTTP_REDIRECT);
}

/**
* Creates a {@link SamlEndpoint} of the specified {@code uri} and the HTTP POST binding protocol.
*/
public static SamlEndpoint ofHttpPost(String uri) {
requireNonNull(uri, "uri");
try {
return ofHttpPost(new URI(uri));
} catch (URISyntaxException e) {
return Exceptions.throwUnsafely(e);
}
}

/**
* Creates a {@link SamlEndpoint} of the specified {@code uri} and the HTTP POST binding protocol.
*/
public static SamlEndpoint ofHttpPost(URI uri) {
requireNonNull(uri, "uri");
return new SamlEndpoint(uri, SamlBindingProtocol.HTTP_POST);
}

private final URI uri;
private final SamlBindingProtocol bindingProtocol;
private final String uriAsString;

private SamlEndpoint(URI uri, SamlBindingProtocol bindingProtocol) {
this.uri = uri;
this.bindingProtocol = bindingProtocol;
uriAsString = uri.toString();
}

/**
* Returns a {@link URI} of this endpoint.
*/
public URI uri() {
return uri;
}

/**
* Returns a {@link URI} of this endpoint as a string.
*/
public String toUriString() {
return uriAsString;
}

/**
* Returns a {@link URI} of this endpoint as a string. The omitted values in the {@link URI} will be
* replaced with the specified default values, such as {@code defaultScheme}, {@code defaultHostname}
* and {@code defaultPort}.
*/
String toUriString(String defaultScheme, String defaultHostname, int defaultPort) {
requireNonNull(defaultScheme, "defaultScheme");
requireNonNull(defaultHostname, "defaultHostname");
validatePort(defaultPort);

final String scheme = firstNonNull(uri.getScheme(), defaultScheme);
final UriComponentsBuilder builder = UriComponentsBuilder.newInstance()
.scheme(scheme)
.host(firstNonNull(uri.getHost(), defaultHostname));

// FIXME Should be applied to armeria upstream!!
final int port = uri.getPort() > 0 ? uri.getPort() : defaultPort;
if (!(port == 80 && "http".equals(scheme) || port == 443 && "https".equals(scheme))) {
builder.port(uri.getPort() > 0 ? uri.getPort() : defaultPort);
}
return builder
.path(uri.getPath())
.toUriString();
}
Comment on lines +115 to +123

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporal handling due to known port erasing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops what's the bug btw?


/**
* Returns a {@link SamlBindingProtocol} of this endpoint.
*/
public SamlBindingProtocol bindingProtocol() {
return bindingProtocol;
}

@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SamlEndpoint)) {
return false;
}
final SamlEndpoint that = (SamlEndpoint) o;
return uri().equals(that.uri()) && bindingProtocol() == that.bindingProtocol();
}

@Override
public int hashCode() {
return uri().hashCode() * 31 + bindingProtocol().hashCode();
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("uri", uri)
.add("bindingProtocol", bindingProtocol)
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

/*
* Copyright 2018 LINE Corporation
*
* LINE Corporation licenses this file to you 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:
*
* https://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.
*/

/**
* <a href="https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language">SAML</a>-based single sign-on
* service.
*/
@NonNullByDefault
package com.linecorp.armeria.server.saml;

import com.linecorp.armeria.common.annotation.NonNullByDefault;
Loading