Skip to content

Commit

Permalink
config directory established
Browse files Browse the repository at this point in the history
  • Loading branch information
sathishjayapal committed Jun 2, 2024
1 parent d211d51 commit d189e00
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 92 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules/
**/*.log
13 changes: 6 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
name: Set up JDK 11
name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '21'
distribution: 'temurin'
cache: maven
-
Expand All @@ -34,8 +34,7 @@ jobs:
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sathishprojects_config_server:latest
run: |
mvn clean package jib:dockerBuild -DskipTests
dockerlogin:login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.OCKERHUB_TOKEN }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/sathishprojects_config_server:latest
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

155 changes: 114 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>me.sathish</groupId>
<artifactId>sathishproject-config-server</artifactId>
<version>+-0.0.1-SNAPSHOT</version>
<name>sathishproject-config-server</name>
<description>Sathish project Portal Config Server</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.1</spring-cloud.version>

</properties>
<dependencies>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>me.sathish</groupId>
<artifactId>sathishproject-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sathishproject-config-server</name>
<description>Sathish project Portal Config Server</description>
<properties>
<java.version>21</java.version>
<spotless.version>2.37.0</spotless.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand All @@ -27,6 +27,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand All @@ -41,28 +45,97 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<finalName>sathishprojects_config_server</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.17.0</version>
<style>AOSP</style>
</googleJavaFormat>
</java>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<to>
<image>travelhelper0h/${project.artifactId}:latest</image>
</to>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package me.sathish.sathishprojectconfigserver;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class BasicAuthBean {

@Value("${pass}")
private String password;

@Value("${username}")
private String username;

Expand All @@ -21,14 +20,10 @@ public void setUsername(String username) {
}

public String getPassword() {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String encodedPassword = encoder.encode(this.password);
return encodedPassword;
return this.password;
}

public void setPassword(String password) {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String encodedPassword = encoder.encode(password);
this.password = encodedPassword;
this.password = password;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
@SpringBootApplication
public class SathishProjectsConfigServerApplication {
public static void main(String[] args) {
System.out.println("The args passed is " + args[0]);
System.out.println("Config server running for all Sathish Projects");
SpringApplication.run(SathishProjectsConfigServerApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,38 +1,54 @@
package me.sathish.sathishprojectconfigserver;

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@Configuration
@EnableWebSecurity(debug = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
final
BasicAuthBean environment;
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)
public class WebSecurityConfig {
final BasicAuthBean environment;

public WebSecurityConfig(BasicAuthBean environment) {
this.environment = environment;
}
@Value("${spring.security.debug:false}")
boolean securityDebug;

//
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.passwordEncoder(new BCryptPasswordEncoder())
.withUser(environment.getUsername())
.password(environment.getPassword())
.roles("ADMIN")
;
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic();
@Bean
public UserDetailsService userDetailsService() {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(
User.withUsername(environment.getUsername())
.password(bCryptPasswordEncoder().encode(environment.getPassword()))
.roles("USER")
.build());
manager.createUser(
User.withUsername(environment.getUsername() + "Admin")
.password(bCryptPasswordEncoder().encode(environment.getPassword()))
.roles("USER", "ADMIN")
.build());
return manager;
}
}


@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return web ->
web.debug(securityDebug)
.ignoring()
.requestMatchers("/css/**", "/js/**", "/img/**", "/lib/**", "/favicon.ico");
}
}
20 changes: 19 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
spring:
application:
name: sathish-projects-git-config-server
h2:
console:
enabled: true
profiles:
active: git
security:
user:
name:
Expand All @@ -10,13 +15,26 @@ spring:
server:
git:
uri: https://github.com/sathishjayapal/jubilant-memory
default-label: main
timeout: 5
clone-on-start: true
search-paths:
- '{application}'
- 'resumes*'
- 'wi-traffic*'
- 'running/*'
server:
port: 8888
# http://localhost:8888/wi-traffic-alerts-url/dev/main dev here is the profile and main in the url
# branch or the main branch name
management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: "*"

encrypt:
key:
key: MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAK8GMsEw44Vw71MsofkIaS5PWKVP1A2yNCxoXNP31VEi4gCUt2ViRkan/c4/WXW7eAOP07Qh7Z287TfZFbgH2oNpVBakuTo5VdmpknZ3z89I4ah36l3+DwaY7JuSSVl0KzDs/xXesmJxBU8gxtNh9AzTvYxuR4bTGPZDMVJuBQ9nAgMBAAECgYAoxQbZnavCD7aP51uriNwHX5BEob3BmvswRPcqoRZdmgSPIhU+VpAMMWGbw4HxPMQOAFjOIwEYt0OCuNyoS5wIkJwYpu5skP5dZ02+TnzZ4LQpEIyLWZtK2BVK/PXTGmMh0zYBE4Ruvx4pwfb0A0nltzY5H5yCR72QMnZloR/T0QJBAPb5MDkobGB19rUezSxUAuCQeLEmdmH5BHD71jtS/EaPCKGkp4ifZ/SO5N8JibyN5MLZ/dDZ51GOWOY4LTn9hbsCQQC1a9DfBVvtJlgtg+aITZwV+rHLKlVP141RbOmoYWJwrubja4fmkQuqXJNfeei3LQ6XclvXHujq9LLCpvlo7cxFAkEAxusDlTXivHqmn1DUrhxoSNjz7LLu7JA1rI6aCSQYvvfbWt4Udez2PLqOyrmS74RVuT78uKeZMU32ek7K1odEmwJBALR8SXTGURjSD+FgGoW5qDHZkO2M9QiUafv6vU4NbDCsX/kaLj58SD25EchncNRjF+QlGicekhvFSt4J3ZC9Gn0CQQDVLHandZGEYx6M1jWzZU8VN/DVUuxrAy3a8kpjxWzCpHCPl2uPr4v4Up3bw8oZwrUG6A06mgV2+bZ4uxkSV7oZ
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
@SpringBootTest
class SathishProjectConfigServerApplicationTests {

@Test
void contextLoads() {
}

@Test
void contextLoads() {}
}
Loading

0 comments on commit d189e00

Please sign in to comment.