You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ki...@apache.org on 2025/12/25 06:31:33 UTC
(linkis) 01/01: support eureka auth
This is an automated email from the ASF dual-hosted git repository.
kinghao pushed a commit to branch feature-support-eureka-auth
in repository https://gitbox.apache.org/repos/asf/linkis.git
commit 8248f376f85d144ee9d63e77602d882957dd894f
Author: kinghao <ki...@apache.org>
AuthorDate: Thu Dec 25 14:30:38 2025 +0800
support eureka auth
---
.../linkis-service-discovery/linkis-eureka/pom.xml | 11 +++++
.../apache/linkis/eureka/EurekaSecurityConfig.java | 55 ++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml
index 3780541468..76e619bf34 100644
--- a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml
+++ b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml
@@ -76,6 +76,17 @@
<artifactId>jersey-apache-client4</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
<build>
<plugins>
diff --git a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/src/main/java/org/apache/linkis/eureka/EurekaSecurityConfig.java b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/src/main/java/org/apache/linkis/eureka/EurekaSecurityConfig.java
new file mode 100644
index 0000000000..233033d4b4
--- /dev/null
+++ b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/src/main/java/org/apache/linkis/eureka/EurekaSecurityConfig.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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
+ *
+ * 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 org.apache.linkis.eureka;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@EnableWebSecurity
+@ConfigurationProperties("auth")
+public class EurekaSecurityConfig extends WebSecurityConfigurerAdapter {
+
+ private static final Logger logger = LoggerFactory.getLogger(EurekaSecurityConfig.class);
+
+ private Boolean enableAuth = false;
+
+ public Boolean getEnableAuth() {
+ return enableAuth;
+ }
+
+ public void setEnableAuth(Boolean enableAuth) {
+ this.enableAuth = enableAuth;
+ }
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().disable();
+ if (!enableAuth) {
+ logger.info("eureka off auth");
+ http.authorizeRequests().anyRequest().permitAll().and().logout().permitAll();
+ } else {
+ logger.info("eureka spring security enable");
+ super.configure(http);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org