Skip to content

Commit 6d1c6ed

Browse files
committed
Last cosmetic changes for v1.3.0
1 parent 1619f53 commit 6d1c6ed

File tree

7 files changed

+67
-53
lines changed

7 files changed

+67
-53
lines changed

docs/getting-started.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,10 @@ See the [Latest release](https://github.com/kamax-matrix/mxisd/releases/latest)
5454
5555
> **NOTE**: Details about configuration syntax and format are described [here](configure.md)
5656
57-
Create/edit a minimal configuration (see installer doc for the location):
58-
```yaml
59-
matrix:
60-
domain: 'example.org'
61-
key:
62-
path: '/path/to/signing.key.file'
63-
storage:
64-
provider:
65-
sqlite:
66-
database: '/path/to/mxisd.db'
67-
```
57+
If you haven't created a configuration file yet, copy `mxisd.example.yaml` to where the configuration file is stored given
58+
your installation method and edit to your needs.
59+
60+
The following items must be at least configured:
6861
- `matrix.domain` should be set to your Homeserver domain (`server_name` in synapse configuration)
6962
- `key.path` will store the signing keys, which must be kept safe! If the file does not exist, keys will be generated for you.
7063
- `storage.provider.sqlite.database` is the location of the SQLite Database file which will hold state (invites, etc.)
@@ -88,7 +81,7 @@ Typical configuration would look like:
8881
<VirtualHost *:443>
8982
ServerName matrix.example.org
9083
91-
...
84+
# ...
9285
9386
ProxyPreserveHost on
9487
ProxyPass /_matrix/identity http://localhost:8090/_matrix/identity
@@ -112,7 +105,7 @@ server {
112105
listen 443 ssl;
113106
server_name matrix.example.org;
114107
115-
...
108+
# ...
116109
117110
location /_matrix/identity {
118111
proxy_pass http://localhost:8090/_matrix/identity;

docs/install/source.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Follow the [build instructions](../build.md) then:
77
# Create a dedicated user
88
useradd -r mxisd
99

10-
# Create config directory and set ownership
10+
# Create config directory
1111
mkdir -p /etc/mxisd
1212

1313
# Create data directory and set ownership
@@ -26,7 +26,7 @@ ln -s /usr/lib/mxisd/mxisd /usr/bin/mxisd
2626
```
2727

2828
### Prepare config file
29-
Copy the sample config file `./mxisd.example.yaml` to `/etc/mxisd/mxisd.yaml`, edit to your needs
29+
Copy the configuration file you've created following the build instructions to `/etc/mxisd/mxisd.yaml`
3030

3131
### Prepare Systemd
3232
1. Copy `src/systemd/mxisd.service` to `/etc/systemd/system/` and edit if needed

src/main/java/edazdarevic/commons/net/CIDRUtils.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
/*
2-
* The MIT License
3-
*
4-
* Copyright (c) 2013 Edin Dazdarevic ([email protected])
5-
6-
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
8-
* in the Software without restriction, including without limitation the rights
9-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
* copies of the Software, and to permit persons to whom the Software is
11-
* furnished to do so, subject to the following conditions:
12-
13-
* The above copyright notice and this permission notice shall be included in
14-
* all copies or substantial portions of the Software.
15-
16-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
* THE SOFTWARE.
23-
*
24-
* */
2+
* The MIT License
3+
*
4+
* Copyright (c) 2013 Edin Dazdarevic ([email protected])
5+
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
2524

2625
package edazdarevic.commons.net;
2726

src/main/java/io/kamax/mxisd/backend/rest/LookupSingleRequestJson.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ public String getMedium() {
3737
public String getAddress() {
3838
return address;
3939
}
40+
4041
}

src/main/java/io/kamax/mxisd/exception/NotAllowedException.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@
2525

2626
public class NotAllowedException extends HttpMatrixException {
2727

28+
public static final String ErrCode = "M_FORBIDDEN";
29+
30+
public NotAllowedException(int code, String s) {
31+
super(code, ErrCode, s);
32+
}
33+
2834
public NotAllowedException(String s) {
29-
super(HttpStatus.SC_FORBIDDEN, "M_FORBIDDEN", s);
35+
super(HttpStatus.SC_FORBIDDEN, ErrCode, s);
3036
}
3137

3238
}

src/main/java/io/kamax/mxisd/session/SessionManager.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ public void bind(String sid, String secret, String mxidRaw) {
178178
}
179179

180180
public void unbind(JsonObject reqData) {
181-
// TODO also check for HS header to know which domain attempting the unbind
182181
if (reqData.entrySet().size() == 2 && reqData.has("mxid") && reqData.has("threepid")) {
183182
/* This is a HS request to remove a 3PID and is considered:
184183
* - An attack on user privacy
@@ -218,11 +217,13 @@ public void unbind(JsonObject reqData) {
218217
}
219218
}
220219
}
220+
221+
throw new NotAllowedException("You have attempted to alter 3PID bindings, which can only be done by the 3PID owner directly. " +
222+
"We have informed the 3PID owner of your fraudulent attempt.");
221223
}
222224

223-
log.info("Denying request");
224-
throw new NotAllowedException("You have attempted to alter 3PID bindings, which can only be done by the 3PID owner directly. " +
225-
"We have informed the 3PID owner of your fraudulent attempt.");
225+
log.info("Denying unbind request as the endpoint is not defined in the spec.");
226+
throw new NotAllowedException(499, "This endpoint does not exist in the spec and therefore is not supported.");
226227
}
227228

228229
}

src/test/java/io/kamax/mxisd/test/notification/EmailNotificationTest.java

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,25 @@
5353
public class EmailNotificationTest {
5454

5555
private final String domain = "localhost";
56+
private final String user = "mxisd";
57+
private final String notifiee = "john";
58+
private final String sender = user + "@" + domain;
59+
private final String senderEmail = "\"Mxisd Server (Unit Test)\" <" + sender + ">";
60+
private final String target = notifiee + "@" + domain;
61+
5662
private Mxisd m;
5763
private GreenMail gm;
5864

5965
@Before
6066
public void before() {
6167
EmailSmtpConfig smtpCfg = new EmailSmtpConfig();
6268
smtpCfg.setPort(3025);
63-
smtpCfg.setLogin("mxisd");
64-
smtpCfg.setPassword("mxisd");
69+
smtpCfg.setLogin(user);
70+
smtpCfg.setPassword(user);
6571

6672
EmailConfig eCfg = new EmailConfig();
6773
eCfg.setConnector(EmailSmtpConnector.ID);
68-
eCfg.getIdentity().setFrom("mxisd@" + domain);
74+
eCfg.getIdentity().setFrom(sender);
6975
eCfg.getIdentity().setName("Mxisd Server (Unit Test)");
7076
eCfg.getConnectors().put(EmailSmtpConnector.ID, GsonUtil.makeObj(smtpCfg));
7177

@@ -92,27 +98,35 @@ public void after() {
9298
public void forMatrixIdInvite() throws MessagingException {
9399
gm.setUser("mxisd", "mxisd");
94100

95-
_MatrixID sender = MatrixID.asAcceptable("mxisd", domain);
96-
_MatrixID recipient = MatrixID.asAcceptable("john", domain);
97-
MatrixIdInvite idInvite = new MatrixIdInvite("!rid:" + domain, sender, recipient, ThreePidMedium.Email.getId(), "john@" + domain, Collections.emptyMap());
101+
_MatrixID sender = MatrixID.asAcceptable(user, domain);
102+
_MatrixID recipient = MatrixID.asAcceptable(notifiee, domain);
103+
MatrixIdInvite idInvite = new MatrixIdInvite(
104+
"!rid:" + domain,
105+
sender,
106+
recipient,
107+
ThreePidMedium.Email.getId(),
108+
target,
109+
Collections.emptyMap()
110+
);
111+
98112
m.getNotif().sendForInvite(idInvite);
99113

100114
assertEquals(1, gm.getReceivedMessages().length);
101115
MimeMessage msg = gm.getReceivedMessages()[0];
102116
assertEquals(1, msg.getFrom().length);
103-
assertEquals("\"Mxisd Server (Unit Test)\" <mxisd@localhost>", msg.getFrom()[0].toString());
117+
assertEquals(senderEmail, msg.getFrom()[0].toString());
104118
assertEquals(1, msg.getRecipients(Message.RecipientType.TO).length);
105119
}
106120

107121
@Test
108122
public void forValidation() throws MessagingException, IOException {
109-
gm.setUser("mxisd", "mxisd");
123+
gm.setUser(user, user);
110124

111125
String token = RandomStringUtils.randomAlphanumeric(128);
112126
ThreePidSession session = new ThreePidSession(
113127
"",
114128
"",
115-
new ThreePid(ThreePidMedium.Email.getId(), "john@" + domain),
129+
new ThreePid(ThreePidMedium.Email.getId(), target),
116130
"",
117131
1,
118132
"",
@@ -124,7 +138,7 @@ public void forValidation() throws MessagingException, IOException {
124138
assertEquals(1, gm.getReceivedMessages().length);
125139
MimeMessage msg = gm.getReceivedMessages()[0];
126140
assertEquals(1, msg.getFrom().length);
127-
assertEquals("\"Mxisd Server (Unit Test)\" <mxisd@localhost>", msg.getFrom()[0].toString());
141+
assertEquals(senderEmail, msg.getFrom()[0].toString());
128142
assertEquals(1, msg.getRecipients(Message.RecipientType.TO).length);
129143

130144
// We just check on the text/plain one. HTML is multipart and it's difficult so we skip

0 commit comments

Comments
 (0)