|
1 | 1 | # Matrix User Verification Service |
2 | 2 |
|
3 | | -Service to verify details of a user based on a Open ID Connect token. |
| 3 | +Service to verify details of a user based on an Open ID Connect token. |
4 | 4 |
|
5 | 5 | Main features: |
6 | 6 |
|
@@ -33,6 +33,136 @@ UVS_PORT=3000 |
33 | 33 | # (Optional) log level, defaults to 'info' |
34 | 34 | # See choices here: https://github.com/winstonjs/winston#logging-levels |
35 | 35 | UVS_LOG_LEVEL=info |
| 36 | +# (Optional) multiple homeserver mode, defaults to disabled |
| 37 | +# See below for more info. |
| 38 | +UVS_OPENID_VERIFY_ANY_HOMESERVER=false |
| 39 | +``` |
| 40 | + |
| 41 | +#### OpenID token verification |
| 42 | + |
| 43 | +UVS can run in a single homeserver mode or be configured to trust any |
| 44 | +homeserver OpenID token. Default is to only trust the configured homeserver |
| 45 | +OpenID tokens. |
| 46 | + |
| 47 | +To enable multiple homeserver mode: |
| 48 | + |
| 49 | + UVS_OPENID_VERIFY_ANY_HOMESERVER=true |
| 50 | + |
| 51 | +Note, room membership is still limited to only the configured `UVS_HOMESERVER_URL`. |
| 52 | + |
| 53 | +When running with the multiple homeserver mode, `matrix_server_name` becomes |
| 54 | +a required request body item for all `/verify` verification API requests. |
| 55 | + |
| 56 | +### API's available |
| 57 | + |
| 58 | +#### Verify OpenID token |
| 59 | + |
| 60 | +Verifies a user OpenID token. |
| 61 | + |
| 62 | + POST /verify/user |
| 63 | + Content-Type: application/json |
| 64 | + |
| 65 | +Request body: |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "token": "secret token" |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +If `UVS_OPENID_VERIFY_ANY_HOMESERVER` is set to `true`, the API also |
| 74 | +requires a `matrix_server_name`, becoming: |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "matrix_server_name": "domain.tld", |
| 79 | + "token": "secret token" |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +Successful validation response: |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "results": { |
| 88 | + "user": true |
| 89 | + }, |
| 90 | + "user_id": "@user:domain.tld" |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +Failed validation: |
| 95 | + |
| 96 | +```json |
| 97 | +{ |
| 98 | + "results": { |
| 99 | + "user": false |
| 100 | + }, |
| 101 | + "user_id": null |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +#### Verify OpenID token and room membership |
| 106 | + |
| 107 | +Verifies a user OpenID token and membership in a room. |
| 108 | + |
| 109 | + POST /verify/user_in_room |
| 110 | + Content-Type: application/json |
| 111 | + |
| 112 | +Request body: |
| 113 | + |
| 114 | +```json |
| 115 | +{ |
| 116 | + "room_id": "!foobar:domain.tld", |
| 117 | + "token": "secret token" |
| 118 | +} |
| 119 | +``` |
| 120 | + |
| 121 | +If `UVS_OPENID_VERIFY_ANY_HOMESERVER` is set to `true`, the API also |
| 122 | +requires a `matrix_server_name`, becoming: |
| 123 | + |
| 124 | +```json |
| 125 | +{ |
| 126 | + "matrix_server_name": "domain.tld", |
| 127 | + "room_id": "!foobar:domain.tld", |
| 128 | + "token": "secret token" |
| 129 | +} |
| 130 | +``` |
| 131 | + |
| 132 | +Successful validation response: |
| 133 | + |
| 134 | +```json |
| 135 | +{ |
| 136 | + "results": { |
| 137 | + "room_membership": true, |
| 138 | + "user": true |
| 139 | + }, |
| 140 | + "user_id": "@user:domain.tld" |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +Failed validation, in case token is not valid: |
| 145 | + |
| 146 | +```json |
| 147 | +{ |
| 148 | + "results": { |
| 149 | + "room_membership": false, |
| 150 | + "user": false |
| 151 | + }, |
| 152 | + "user_id": null |
| 153 | +} |
| 154 | +``` |
| 155 | + |
| 156 | +In the token was validated but user is not in room, the failed response is: |
| 157 | + |
| 158 | +```json |
| 159 | +{ |
| 160 | + "results": { |
| 161 | + "room_membership": false, |
| 162 | + "user": true |
| 163 | + }, |
| 164 | + "user_id": "@user:domain.tld" |
| 165 | +} |
36 | 166 | ``` |
37 | 167 |
|
38 | 168 | ### Running |
|
0 commit comments