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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can run a farm of jSynapse servers, pointing all to the same MongoDB instanc
By deafult jSynapse homeserver accepts requests on port 5555. You can change this by passing --port.server={PORT}
To start with a different domain (default swarmcom.org) use --domain=mydomain.org

To check server health point browser to http://localhost:5555/health
To check server health point browser to http://localhost:5555/actuator/health

Examples to get/set user display name and avatar url

Expand All @@ -43,3 +43,9 @@ curl http://localhost:5555/_matrix/client/api/v1/profile/@mirceac:swarmcom.org/a
{"avatar_url":"url"}


## Check

```shell
mvn versions:display-plugin-updates
```

9 changes: 9 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
mongo:
image: mongo:4.4.6
container_name: mongo_container
restart: always
environment:
MONGO_INITDB_DATABASE: matrix
ports:
- "27017:27017"
139 changes: 92 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>
<version>3.3.3</version>
</parent>

<dependencies>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<!-- Add other repositories if needed -->
</repositories>

<!-- Spring Boot -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -45,60 +45,77 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!--dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-remote-shell</artifactId>
</dependency-->

<!-- Hibernate validator -->

<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.1.Final</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<version>3.17.0</version>
</dependency>

<dependency>
<groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId>
<artifactId>recaptcha4j</artifactId>
<version>0.0.8</version>
</dependency>

<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.20</version>
</dependency>

<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>2.0.1</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>


<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.16.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId>
<artifactId>recaptcha4j</artifactId>
<version>0.0.8</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<properties>
<java.version>1.7</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand All @@ -110,25 +127,53 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check>
<branchRate>90</branchRate>
<lineRate>90</lineRate>
<haltOnFailure>false</haltOnFailure>
<totalBranchRate>90</totalBranchRate>
<totalLineRate>90</totalLineRate>
<packageLineRate>90</packageLineRate>
<packageBranchRate>90</packageBranchRate>
</check>
</configuration>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version> <!-- Use the latest version -->
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>com.github.spotbugs</groupId>-->
<!-- <artifactId>spotbugs-maven-plugin</artifactId>-->
<!-- <version>4.8.6.3</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>check</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>check</goal>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.9.5</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/swarmcom/jsynapse/JSynapseServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,18 @@
import org.springframework.data.mongodb.config.EnableMongoAuditing;

import static org.springframework.boot.SpringApplication.run;
import static org.apache.commons.lang3.StringUtils.substringAfter;

@SpringBootApplication
@Configuration
@PropertySource(value = "classpath:jsynapse.properties", ignoreResourceNotFound = true)
@EnableMongoAuditing
public class JSynapseServer {
public static String DOMAIN = "swarmcom.org";

@Bean(name = "customProps")
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

public static void main(String[] args) {
if (args.length > 0) {
for (String arg : args) {
if (arg.startsWith("--domain")) {
DOMAIN = substringAfter(arg, "=");
}
}
}
run(JSynapseServer.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
package org.swarmcom.jsynapse.controller;

import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
*/
package org.swarmcom.jsynapse.controller;

import jakarta.validation.ValidationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.swarmcom.jsynapse.service.exception.EntityAlreadyExistsException;
import org.swarmcom.jsynapse.service.exception.EntityNotFoundException;
import org.swarmcom.jsynapse.service.exception.InvalidRequestException;
import org.swarmcom.jsynapse.service.exception.TokenNotFoundException;

import javax.validation.ValidationException;

import static org.springframework.http.HttpStatus.*;

public class JsynapseApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
*/
package org.swarmcom.jsynapse.controller.client.api.v1;

import jakarta.inject.Inject;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import org.swarmcom.jsynapse.controller.JsynapseApi;
import org.swarmcom.jsynapse.domain.Authentication.AuthenticationFlows;
import org.swarmcom.jsynapse.domain.Authentication.AuthenticationResult;
import org.swarmcom.jsynapse.domain.Authentication.AuthenticationSubmission;
import org.swarmcom.jsynapse.domain.Authentication.AuthenticationFlows;
import org.swarmcom.jsynapse.service.authentication.AuthenticationService;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

import static org.springframework.web.bind.annotation.RequestMethod.*;
import static org.swarmcom.jsynapse.controller.JsynapseApi.CLIENT_V1_API;

@RestController
Expand All @@ -40,28 +38,24 @@ public AuthenticationRestApi(final AuthenticationService authenticationService)
this.authenticationService = authenticationService;
}

@RequestMapping(value = "/login", method = GET)
public @ResponseBody
AuthenticationFlows getLoginSchemas() {
@GetMapping("/login")
public AuthenticationFlows getLoginSchemas() {
return authenticationService.getSupportedFlows();
}

@RequestMapping(value = "/login", method = POST)
public @ResponseBody
AuthenticationResult login(@RequestBody final AuthenticationSubmission login, HttpServletRequest request) {
@PostMapping("/login")
public AuthenticationResult login(@RequestBody final AuthenticationSubmission login, HttpServletRequest request) {
login.setRemoteAddr(request.getRemoteAddr());
return authenticationService.login(login);
}

@RequestMapping(value = "/register", method = GET)
public @ResponseBody
AuthenticationFlows getRegistrationSchemas() {
@GetMapping("/register")
public AuthenticationFlows getRegistrationSchemas() {
return authenticationService.getSupportedFlows();
}

@RequestMapping(value = "/register", method = POST)
public @ResponseBody
AuthenticationResult register(@RequestBody final AuthenticationSubmission registration, HttpServletRequest request) {
@PostMapping("/register")
public AuthenticationResult register(@RequestBody final AuthenticationSubmission registration, HttpServletRequest request) {
registration.setRemoteAddr(request.getRemoteAddr());
return authenticationService.register(registration);
}
Expand Down
Loading