Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow connecting to unsafe network wifi #1687

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/frontend/src/components/wifi/ConnectionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

<v-row>
<v-card
v-if="!show_password_input_box"
v-if="!show_password_input_box && is_secure"
elevation="0"
@click="toggleForcePassword()"
>
Expand Down Expand Up @@ -175,6 +175,9 @@ export default Vue.extend({
}
return true
},
is_secure(): boolean {
return this.network.locked
},
connecting(): boolean {
return this.connection_status === ConnectionStatus.Connecting
},
Expand Down
27 changes: 19 additions & 8 deletions core/services/wifi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,31 @@ async def connect(credentials: WifiCredentials, hidden: bool = False) -> Any:
logger.info("Network is not known.")
is_new_network = True

if credentials.password == "" and network_id is None:
is_secure = False
try:
available_networks = await wifi_manager.get_wifi_available()
scanned_network = next(filter(lambda network: network.ssid == credentials.ssid, available_networks))
flags_for_passwords = ["WPA", "WEP", "WSN"]
for candidate in flags_for_passwords:
if candidate in scanned_network.flags:
is_secure = True
break
except StopIteration:
logger.info("Could not find wifi network around.")

if credentials.password == "" and network_id is None and is_secure:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="No password received and network not found among saved ones.",
)

try:
if credentials.password != "":
if network_id:
logger.info("Removing old entry for known network.")
await wifi_manager.remove_network(network_id)
else:
logger.info("Saving new network entry.")
network_id = await wifi_manager.add_network(credentials, hidden)
if network_id:
logger.info("Removing old entry for known network.")
await wifi_manager.remove_network(network_id)
else:
logger.info("Saving new network entry.")
network_id = await wifi_manager.add_network(credentials, hidden)

logger.info("Performing network connection.")
if network_id is None:
Expand Down