Enforce authentication on all endpoints when auth is configured.
()
| 106 | # PROVENANCE / ORIGIN VERIFICATION |
| 107 | # Reports authorship and whether this checkout is the official repository or a |
| 108 | # fork. The mobile app reads this on connect. It is an attribution signal, not |
| 109 | # a security control — a fork can edit it — but it keeps forks honest. |
| 110 | # ============================================================================ |
| 111 | |
| 112 | @app.route('/api/provenance') |
| 113 | def api_provenance(): |
| 114 | try: |
| 115 | import provenance |
| 116 | return jsonify(provenance.verify(os.path.dirname(os.path.abspath(__file__)))) |
| 117 | except Exception as _prov_err: # pragma: no cover - defensive |
| 118 | return jsonify({ |
| 119 | 'canonical_repo': 'https://github.com/PierreGode/Ragnar.git', |
| 120 | 'official': False, |
| 121 | 'error': str(_prov_err), |
| 122 | }) |
| 123 | |
| 124 | # ============================================================================ |
| 125 | # BLE PROVISIONING |
| 126 | # The Bluetooth GATT peripheral the mobile app uses to discover this box and |
| 127 | # learn its IP (see ble_provisioning.py + Ragnarmobile docs/PROTOCOL.md). It is |
| 128 | # provisioning-only: no dashboard data ever crosses Bluetooth. Off by default, |
| 129 | # because advertising as a peripheral contends with bt_scanner's active scans |
| 130 | # on the same adapter. |
| 131 | # ============================================================================ |
| 132 | |
| 133 | _ble_server = None |
| 134 | _ble_lock = threading.Lock() |
| 135 | |
| 136 | |
| 137 | def _ble_ap_state(): |
| 138 | """Live hotspot state for the netStatus characteristic.""" |
| 139 | active = bool(getattr(shared_data, 'wardrive_ap_active', False)) |
| 140 | wm = getattr(shared_data, 'wifi_manager', None) |
| 141 | ssid = None |
| 142 | if active: |
| 143 | ssid = getattr(wm, 'ap_ssid', None) or shared_data.config.get('wifi_ap_ssid', 'Ragnar') |
| 144 | return {'active': active, 'ssid': ssid} |
| 145 | |
| 146 | |
| 147 | def _ble_set_ap(on): |
| 148 | """Bring the hotspot up/down from a bonded AP-control write.""" |
| 149 | wm = getattr(shared_data, 'wifi_manager', None) |
| 150 | if wm is None: |
| 151 | raise RuntimeError('Wi-Fi manager not available') |
nothing calls this directly
no test coverage detected