forked from Hithomelabs/CFTunnels
Compare commits
No commits in common. "0d576eb9a7f6b557a88d72e8d3e728139d9bea25" and "fb4ff607299f337d6c911a8f94f8844f26c725f6" have entirely different histories.
0d576eb9a7
...
fb4ff60729
@ -27,9 +27,6 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
|
||||||
runtimeOnly 'org.postgresql:postgresql'
|
|
||||||
implementation 'org.hibernate.validator:hibernate-validator'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
|
|||||||
@ -12,20 +12,6 @@ services:
|
|||||||
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
|
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
|
||||||
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
|
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
|
||||||
- HOST_PORT=${HOST_PORT}
|
- HOST_PORT=${HOST_PORT}
|
||||||
- POSTGRES_USER=${POSTGRES_USERNAME}
|
|
||||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
|
||||||
env_file:
|
env_file:
|
||||||
- stack.env
|
- stack.env
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
postgres:
|
|
||||||
image: postgres:15-alpine
|
|
||||||
container_name: cftunnel-db
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: cftunnel
|
|
||||||
POSTGRES_USER: ${POSTGRES_USERNAME}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "${DB_PORT}:5432"
|
|
||||||
volumes:
|
|
||||||
- ${DB_PATH}:/var/lib/postgresql/data
|
|
||||||
@ -11,12 +11,12 @@ import java.util.ArrayList;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class OpenApiConfig {
|
public class OpenApiConfig {
|
||||||
|
|
||||||
@Value("${api.baseUrl}")
|
@Value("${api.corsResolveUrl}")
|
||||||
private String baseUrl;
|
private String corsResolveUrl;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI openAPI(){
|
public OpenAPI openAPI(){
|
||||||
Server httpsServer = new Server().url(baseUrl);
|
Server httpsServer = new Server().url(corsResolveUrl);
|
||||||
OpenAPI openApi = new OpenAPI();
|
OpenAPI openApi = new OpenAPI();
|
||||||
ArrayList<Server> servers = new ArrayList<>();
|
ArrayList<Server> servers = new ArrayList<>();
|
||||||
servers.add(httpsServer);
|
servers.add(httpsServer);
|
||||||
|
|||||||
@ -29,9 +29,8 @@ public class SecuirtyConfig {
|
|||||||
http
|
http
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
).csrf(csrf -> csrf.disable())
|
)
|
||||||
.with(new OAuth2LoginConfigurer<>(),
|
.with(new OAuth2LoginConfigurer<>(), oauth2 -> oauth2.userInfoEndpoint(u -> u.oidcUserService(customOidcUserConfiguration)));
|
||||||
oauth2 -> oauth2.userInfoEndpoint(u -> u.oidcUserService(customOidcUserConfiguration)));
|
|
||||||
|
|
||||||
|
|
||||||
return http.build();
|
return http.build();
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public class TunnelController implements ErrorController {
|
|||||||
return ResponseEntity.ok(jsonResponse);
|
return ResponseEntity.ok(jsonResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 50df9101-f625-4618-b7c5-100338a57124
|
// 50df9101-f625-4618-b7c5-100338a57124
|
||||||
@PreAuthorize("hasAnyRole('ADMIN')")
|
@PreAuthorize("hasAnyRole('ADMIN')")
|
||||||
@PutMapping("/tunnel/{tunnelId}/add")
|
@PutMapping("/tunnel/{tunnelId}/add")
|
||||||
public ResponseEntity<Map<String, Object>> addTunnelconfiguration(@PathVariable String tunnelId, @RequestBody Ingress ingress) throws JsonProcessingException {
|
public ResponseEntity<Map<String, Object>> addTunnelconfiguration(@PathVariable String tunnelId, @RequestBody Ingress ingress) throws JsonProcessingException {
|
||||||
|
|||||||
@ -1,10 +1 @@
|
|||||||
api.baseUrl=http://localhost:8080
|
api.corsResolveUrl=http://localhost:8080
|
||||||
|
|
||||||
management.health.db.enabled=true
|
|
||||||
management.endpoints.web.exposure.include=health
|
|
||||||
management.endpoint.health.show-details=always
|
|
||||||
|
|
||||||
logging.level.org.hibernate.SQL=DEBUG
|
|
||||||
debug=true
|
|
||||||
|
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/cftunnel
|
|
||||||
@ -1 +1 @@
|
|||||||
api.baseUrl=https://cftunnels.hithomelabs.com
|
api.corsResolveUrl=https://cftunnels.hithomelabs.com
|
||||||
@ -1 +1 @@
|
|||||||
api.baseUrl=https://testcf.hithomelabs.com
|
api.corsResolveUrl=https://testcf.hithomelabs.com
|
||||||
@ -4,12 +4,6 @@ cloudflare.apiKey=${CLOUDFLARE_API_KEY}
|
|||||||
cloudflare.email=${CLOUDFLARE_EMAIL}
|
cloudflare.email=${CLOUDFLARE_EMAIL}
|
||||||
spring.profiles.active=${ENV}
|
spring.profiles.active=${ENV}
|
||||||
|
|
||||||
# set root level
|
|
||||||
logging.level.root=INFO
|
|
||||||
# package-specific
|
|
||||||
logging.level.org.springframework=TRACE
|
|
||||||
logging.level.com.myapp=INFO
|
|
||||||
|
|
||||||
/ * * Masking sure app works behind a reverse proxy
|
/ * * Masking sure app works behind a reverse proxy
|
||||||
server.forward-headers-strategy=framework
|
server.forward-headers-strategy=framework
|
||||||
|
|
||||||
@ -23,15 +17,3 @@ spring.security.oauth2.client.provider.cftunnels.token-uri=https://auth.hithomel
|
|||||||
spring.security.oauth2.client.provider.cftunnels.user-info-uri=https://auth.hithomelabs.com/application/o/userinfo/
|
spring.security.oauth2.client.provider.cftunnels.user-info-uri=https://auth.hithomelabs.com/application/o/userinfo/
|
||||||
spring.security.oauth2.client.provider.cftunnels.jwk-set-uri=https://auth.hithomelabs.com/application/o/cftunnels/jwks/
|
spring.security.oauth2.client.provider.cftunnels.jwk-set-uri=https://auth.hithomelabs.com/application/o/cftunnels/jwks/
|
||||||
spring.security.oauth2.client.provider.cftunnels.issuer-uri=https://auth.hithomelabs.com/application/o/cftunnels/
|
spring.security.oauth2.client.provider.cftunnels.issuer-uri=https://auth.hithomelabs.com/application/o/cftunnels/
|
||||||
|
|
||||||
spring.datasource.url=jdbc:postgresql://192.168.0.100:5432/cftunnel
|
|
||||||
spring.datasource.username=${POSTGRES_USERNAME}
|
|
||||||
spring.datasource.password=${POSTGRES_PASSWORD}
|
|
||||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
|
||||||
spring.sql.init.mode=never
|
|
||||||
|
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
|
||||||
spring.jpa.show-sql=true
|
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
|
||||||
|
|
||||||
spring.jpa.open-in-view=false
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
-- schema.sql
|
|
||||||
|
|
||||||
-- Roles table
|
|
||||||
CREATE TABLE IF NOT EXISTS roles (
|
|
||||||
role_id SERIAL PRIMARY KEY,
|
|
||||||
role_name VARCHAR(50) UNIQUE NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Users table
|
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
user_id SERIAL PRIMARY KEY,
|
|
||||||
user_name VARCHAR(100) NOT NULL,
|
|
||||||
password VARCHAR(255) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- User-Role Mapping table (many-to-many relationship)
|
|
||||||
CREATE TABLE IF NOT EXISTS user_role_mapping (
|
|
||||||
mapping_id SERIAL PRIMARY KEY,
|
|
||||||
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
|
|
||||||
role_id INTEGER NOT NULL REFERENCES roles(role_id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Tunnels table
|
|
||||||
CREATE TABLE IF NOT EXISTS tunnels (
|
|
||||||
tunnel_id SERIAL PRIMARY KEY,
|
|
||||||
tunnel_name VARCHAR(100) NOT NULL,
|
|
||||||
tunnel_type VARCHAR(50) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Mapping Requests table
|
|
||||||
CREATE TABLE IF NOT EXISTS mapping_requests (
|
|
||||||
request_id SERIAL PRIMARY KEY,
|
|
||||||
request_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
status VARCHAR(20) NOT NULL,
|
|
||||||
user_id INTEGER REFERENCES users(user_id) ON DELETE SET NULL,
|
|
||||||
tunnel_id INTEGER REFERENCES tunnels(tunnel_id) ON DELETE SET NULL
|
|
||||||
);
|
|
||||||
Loading…
Reference in New Issue
Block a user