diff options
| author | omnom62 <omnom62@outlook.com> | 2026-08-12 14:38:00 +1000 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2026-08-26 13:33:34 -0500 |
| commit | d62e57071f2afb83879f576f6a3af5ecaa21023b (patch) | |
| tree | c46867432e1cb2e9321899590adde02506343b46 /src/services/vyos-http-api-server | |
| parent | a4a52a0975ce4de70c43fa6cab1e09f55567dc35 (diff) | |
| download | vyos-1x-d62e57071f2afb83879f576f6a3af5ecaa21023b.tar.gz vyos-1x-d62e57071f2afb83879f576f6a3af5ecaa21023b.zip | |
http-api: T8989: address review comments
- Make ApiModel.key optional to allow Bearer/X-API-Key/mTLS auth
without requiring a dummy key field in the request body
- Add thread safety to REST token secret initialization
- Cast rest_token_exp and rest_secret_len to int on load
- Use defensive dict.get() for authentication config access
Diffstat (limited to 'src/services/vyos-http-api-server')
| -rwxr-xr-x | src/services/vyos-http-api-server | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index 4039d17a2..bdcf24e39 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -184,9 +184,13 @@ def initialization(session: SessionState, app: FastAPI = app): rest_config = server_config.get('rest', {}) session.debug = bool('debug' in rest_config) session.strict = bool('strict' in rest_config) - if isinstance(rest_config, dict) and 'authentication' in rest_config: - session.rest_token_exp = rest_config['authentication']['expiration'] - session.rest_secret_len = rest_config['authentication']['secret_length'] + if isinstance(rest_config, dict): + auth = rest_config.get('authentication', {}) + if isinstance(auth, dict): + if 'expiration' in auth: + session.rest_token_exp = int(auth['expiration']) + if 'secret_length' in auth: + session.rest_secret_len = int(auth['secret_length']) graphql_config = server_config.get('graphql', {}) session.origins = graphql_config.get('cors', {}).get('allow_origin', []) |
