diff --git a/src/main/groovy/io/kamax/mxisd/controller/v1/InvitationController.groovy b/src/main/groovy/io/kamax/mxisd/controller/v1/InvitationController.groovy index aadf3ed..e83b00d 100644 --- a/src/main/groovy/io/kamax/mxisd/controller/v1/InvitationController.groovy +++ b/src/main/groovy/io/kamax/mxisd/controller/v1/InvitationController.groovy @@ -32,6 +32,8 @@ import io.kamax.mxisd.key.KeyManager import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.CrossOrigin import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @@ -41,6 +43,8 @@ import javax.servlet.http.HttpServletRequest import static org.springframework.web.bind.annotation.RequestMethod.POST @RestController +@CrossOrigin +@RequestMapping(path = "/_matrix/identity/api/v1", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) class InvitationController { private Logger log = LoggerFactory.getLogger(InvitationController.class) @@ -56,7 +60,7 @@ class InvitationController { private Gson gson = new Gson() - @RequestMapping(value = "/_matrix/identity/api/v1/store-invite", method = POST) + @RequestMapping(value = "/store-invite", method = POST) String store( HttpServletRequest request, @RequestParam String sender, diff --git a/src/main/groovy/io/kamax/mxisd/controller/v1/KeyController.groovy b/src/main/groovy/io/kamax/mxisd/controller/v1/KeyController.groovy index f74b5bf..7c583e7 100644 --- a/src/main/groovy/io/kamax/mxisd/controller/v1/KeyController.groovy +++ b/src/main/groovy/io/kamax/mxisd/controller/v1/KeyController.groovy @@ -28,16 +28,16 @@ import org.apache.commons.lang.StringUtils import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.* import javax.servlet.http.HttpServletRequest import static org.springframework.web.bind.annotation.RequestMethod.GET @RestController +@CrossOrigin +@RequestMapping(path = "/_matrix/identity/api/v1", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) class KeyController { private Logger log = LoggerFactory.getLogger(KeyController.class) @@ -45,7 +45,7 @@ class KeyController { @Autowired private KeyManager keyMgr - @RequestMapping(value = "/_matrix/identity/api/v1/pubkey/{keyType}:{keyId}", method = GET) + @RequestMapping(value = "/pubkey/{keyType}:{keyId}", method = GET) String getKey(@PathVariable String keyType, @PathVariable int keyId) { if (!"ed25519".contentEquals(keyType)) { throw new BadRequestException("Invalid algorithm: " + keyType) @@ -57,14 +57,14 @@ class KeyController { ]) } - @RequestMapping(value = "/_matrix/identity/api/v1/pubkey/ephemeral/isvalid", method = GET) + @RequestMapping(value = "/pubkey/ephemeral/isvalid", method = GET) String checkEphemeralKeyValidity(HttpServletRequest request) { log.error("{} was requested but not implemented", request.getRequestURL()) throw new NotImplementedException() } - @RequestMapping(value = "/_matrix/identity/api/v1/pubkey/isvalid", method = GET) + @RequestMapping(value = "/pubkey/isvalid", method = GET) String checkKeyValidity(HttpServletRequest request, @RequestParam("public_key") String pubKey) { log.info("Validating public key {}", pubKey) diff --git a/src/main/groovy/io/kamax/mxisd/controller/v1/SessionController.groovy b/src/main/groovy/io/kamax/mxisd/controller/v1/SessionController.groovy index 3fc9241..41aafcd 100644 --- a/src/main/groovy/io/kamax/mxisd/controller/v1/SessionController.groovy +++ b/src/main/groovy/io/kamax/mxisd/controller/v1/SessionController.groovy @@ -33,16 +33,16 @@ import org.apache.http.HttpStatus import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.* import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletResponse import java.nio.charset.StandardCharsets @RestController +@CrossOrigin +@RequestMapping(path = "/_matrix/identity/api/v1", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) class SessionController { @Autowired @@ -56,7 +56,7 @@ class SessionController { gson.fromJson(new InputStreamReader(req.getInputStream(), StandardCharsets.UTF_8), obj) } - @RequestMapping(value = "/_matrix/identity/api/v1/validate/{medium}/requestToken") + @RequestMapping(value = "/validate/{medium}/requestToken") String init(HttpServletRequest request, HttpServletResponse response, @PathVariable String medium) { log.info("Requested: {}", request.getRequestURL(), request.getQueryString()) @@ -77,7 +77,7 @@ class SessionController { return gson.toJson(obj) } - @RequestMapping(value = "/_matrix/identity/api/v1/validate/{medium}/submitToken") + @RequestMapping(value = "/validate/{medium}/submitToken") String validate(HttpServletRequest request, @RequestParam String sid, @RequestParam("client_secret") String secret, @RequestParam String token) { @@ -88,7 +88,7 @@ class SessionController { return "{}" } - @RequestMapping(value = "/_matrix/identity/api/v1/3pid/getValidated3pid") + @RequestMapping(value = "/3pid/getValidated3pid") String check(HttpServletRequest request, HttpServletResponse response, @RequestParam String sid, @RequestParam("client_secret") String secret) { log.info("Requested: {}?{}", request.getRequestURL(), request.getQueryString()) @@ -115,7 +115,7 @@ class SessionController { } } - @RequestMapping(value = "/_matrix/identity/api/v1/3pid/bind") + @RequestMapping(value = "/3pid/bind") String bind(HttpServletRequest request, HttpServletResponse response, @RequestParam String sid, @RequestParam("client_secret") String secret, @RequestParam String mxid) { String data = IOUtils.toString(request.getReader())