where('key_type', ApiKey::TYPE_APPLICATION) ->where('r_nodes', true) ->first(); // We couldn't find a key that exists for this user with only permission for // reading nodes. Go ahead and create it now. if (!$key) { $key = $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([ 'memo' => 'Automatically generated node deployment key.', 'user_id' => $request->user()->id, ], ['r_nodes' => true]); } $token = $key->identifier . $key->token; if (!$token) { return null; } return sprintf( '%s wings configure --panel-url %s --token %s --node %d%s', $docker ? 'docker compose exec -it' : 'sudo', config('app.url'), $token, $node->id, $request->isSecure() ? '' : ' --allow-insecure' ); } }