diff options
author | Jorik Schellekens <joriks@matrix.org> | 2019-08-27 14:12:13 +0100 |
---|---|---|
committer | Jorik Schellekens <joriks@matrix.org> | 2019-08-28 15:59:54 +0100 |
commit | 01d05e40a9b5ff1c97a587d5fe2617b77c54212d (patch) | |
tree | bf9f3857199bb7faefc8e232cb246c3853bcb233 | |
parent | Fix validation wrapper to work for oop. (diff) | |
download | synapse-01d05e40a9b5ff1c97a587d5fe2617b77c54212d.tar.xz |
Remove use of servername endpoint
-rw-r--r-- | synapse_topology/server/schemas.py | 9 | ||||
-rw-r--r-- | synapse_topology/server/server.py | 9 | ||||
-rw-r--r-- | synapse_topology/webui/src/js/actions/index.js | 18 | ||||
-rw-r--r-- | synapse_topology/webui/src/js/api/index.js | 23 | ||||
-rw-r--r-- | synapse_topology/webui/src/js/containers/ServerName.js | 3 | ||||
-rw-r--r-- | synapse_topology/webui/src/js/containers/StatsReporter.js | 3 |
6 files changed, 23 insertions, 42 deletions
diff --git a/synapse_topology/server/schemas.py b/synapse_topology/server/schemas.py index 2197b96e24..17f1dfb45a 100644 --- a/synapse_topology/server/schemas.py +++ b/synapse_topology/server/schemas.py @@ -1,12 +1,3 @@ -SERVERNAME_SCHEMA = { - "type": "object", - "properties": { - "server_name": {"type": "string", "minlength": 1}, - "report_stats": {"type": "boolean"}, - }, - "required": ["server_name", "report_stats"], -} - BASE_CONFIG_SCHEMA = { "type": "object", "properties": { diff --git a/synapse_topology/server/server.py b/synapse_topology/server/server.py index 351f7d49e3..02ca013b24 100644 --- a/synapse_topology/server/server.py +++ b/synapse_topology/server/server.py @@ -10,7 +10,6 @@ from .utils import port_checker from synapse_topology.model import constants from .schemas import ( BASE_CONFIG_SCHEMA, - SERVERNAME_SCHEMA, CERT_PATHS_SCHEMA, CERTS_SCHEMA, PORTS_SCHEMA, @@ -46,10 +45,12 @@ class Server: } ) - @app.route("/secretkey", methods=["GET"]) + @app.route("/secretkey", methods=["POST"]) @validate_schema(SECRET_KEY_SCHEMA) - def get_secret_key(self, request): - return json.dumps({"secret_key": self.model.generate_secret_key()}) + def get_secret_key(self, request, body): + return json.dumps( + {"secret_key": self.model.generate_secret_key(body["server_name"])} + ) @app.route("/config", methods=["GET"]) def get_config(self, request): diff --git a/synapse_topology/webui/src/js/actions/index.js b/synapse_topology/webui/src/js/actions/index.js index d55e920c99..7aa04ff212 100644 --- a/synapse_topology/webui/src/js/actions/index.js +++ b/synapse_topology/webui/src/js/actions/index.js @@ -26,7 +26,6 @@ import { import { getServerSetup, - postServerName, getSecretkey, postCertPaths, postCerts, @@ -61,17 +60,10 @@ const setConfigDir = dir => ({ configDir: dir, }); -export const generateSecretKeys = consent => { - - return (dispatch, getState) => { - - dispatch(gettingSecretKeys()); - postServerName(getState().baseConfig.servername, consent) - .then( - result => dispatch(getSecretKey()), - error => dispatch(fail(error)), - ); +export const generateSecretKeys = serverName => { + return dispatch => { + dispatch(getSecretKey(serverName)) }; }; @@ -162,11 +154,11 @@ export const gettingSecretKeys = () => ({ type: GETTING_SECRET_KEY, }); -export const getSecretKey = () => { +export const getSecretKey = serverName => { return dispatch => { - getSecretkey().then( + getSecretkey(serverName).then( result => dispatch(setSecretKey(result)), error => dispatch(fail(error)), ) diff --git a/synapse_topology/webui/src/js/api/index.js b/synapse_topology/webui/src/js/api/index.js index c839b8a78c..cd9e4bfb2b 100644 --- a/synapse_topology/webui/src/js/api/index.js +++ b/synapse_topology/webui/src/js/api/index.js @@ -16,17 +16,6 @@ export const getServerName = () => fetchAbs(SERVER_NAME) .then(res => res.json()) -export const postServerName = (servername, consent) => - fetchAbs( - SERVER_NAME, - { - method: 'POST', - body: JSON.stringify({ - "server_name": servername, - "report_stats": consent, - }), - }, - ) export const postCertPaths = (certPath, certKeyPath) => fetchAbs( @@ -66,8 +55,16 @@ export const testPorts = (ports) => }, ).then(res => res.json()) -export const getSecretkey = () => - fetchAbs(SECRET_KEY) +export const getSecretkey = serverName => + fetchAbs( + SECRET_KEY, + { + method: 'POST', + body: JSON.stringify({ + server_name: serverName, + }) + } + ) .then(res => res.json()) .then(json => json.secret_key) diff --git a/synapse_topology/webui/src/js/containers/ServerName.js b/synapse_topology/webui/src/js/containers/ServerName.js index e26e97093c..fe4cbcb1b7 100644 --- a/synapse_topology/webui/src/js/containers/ServerName.js +++ b/synapse_topology/webui/src/js/containers/ServerName.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import ServerName from '../components/ServerName'; -import { advanceUI, setServername } from '../actions'; +import { advanceUI, setServername, generateSecretKeys } from '../actions'; const mapStateToProps = (state, ownProps) => ({ @@ -13,6 +13,7 @@ const mapDispathToProps = (dispatch) => ({ dispatch(advanceUI()); dispatch(setServername(servername)); + dispatch(generateSecretKeys(servername)); }, }); diff --git a/synapse_topology/webui/src/js/containers/StatsReporter.js b/synapse_topology/webui/src/js/containers/StatsReporter.js index c7e3b06966..ac006b4538 100644 --- a/synapse_topology/webui/src/js/containers/StatsReporter.js +++ b/synapse_topology/webui/src/js/containers/StatsReporter.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import StatsReporter from '../components/StatsReporter'; -import { advanceUI, setStats, generateSecretKeys } from '../actions'; +import { advanceUI, setStats } from '../actions'; const mapStateToProps = (state, ownProps) => ({ @@ -13,7 +13,6 @@ const mapDispathToProps = (dispatch) => ({ dispatch(advanceUI()); dispatch(setStats(consent)); - dispatch(generateSecretKeys(consent)) }, }); |