Skip to content
Open

Main #18

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d52903c
update mission to run on LL2.0
Jan 3, 2022
b1cc370
update mxfirewall to v1
Jan 3, 2022
1a40495
update mqtt script with v1 API
Jan 5, 2022
68b1d3d
update webhook path to be able to run in postman and LL2.0 container
Jan 12, 2022
fba7fb8
commenting out debug print statements
Jan 17, 2022
d921d79
adding python sdk file
Jan 20, 2022
dd11141
add meraki sdk v1.15.0 to requirements.txt
Jan 20, 2022
f0aff67
Update webhookreceiver.py
denapom11 Feb 15, 2022
b559913
Update mission_captive_portal.py
denapom11 Feb 15, 2022
5fdbba3
Update meraki_sample_captive_portal.py
denapom11 Feb 15, 2022
abf4b03
Update meraki_sample_webhook_receiver.py
denapom11 Feb 15, 2022
48fcb66
Update excapsimulator.py
denapom11 Feb 15, 2022
c8b2a39
Update meraki_cloud_simulator.py
denapom11 Feb 15, 2022
f2e7479
updating template to accept API entered values
denapom11 Feb 17, 2022
93c27cd
updating sim to match api
denapom11 Feb 17, 2022
69415b2
updating to be able to run locally and in LL2.0
denapom11 Feb 17, 2022
3d3d84c
update for excap to run locally and in ll2.0
denapom11 Feb 17, 2022
63130da
upating to work locally and in LL2.0
denapom11 Feb 17, 2022
db73db7
fix host value
denapom11 Feb 17, 2022
0454bae
fix to run locally and in ll2.0
denapom11 Feb 17, 2022
e828cf1
fix
denapom11 Feb 17, 2022
10e2bcb
Update mission_captive_portal.py
denapom11 Feb 17, 2022
a67698d
Update excapsimulator.py
denapom11 Feb 17, 2022
84339bb
Update excapsimulator.py
denapom11 Feb 17, 2022
679ac2e
Update excapsimulator.py
denapom11 Feb 17, 2022
6d0b6e7
Update excapsimulator.py
denapom11 Feb 17, 2022
7d09087
Update mission_captive_portal.py
denapom11 Feb 17, 2022
eb9ac01
Update external_captive_portal.py
denapom11 Feb 17, 2022
e4a0b11
Update excapsimulator.py
denapom11 Feb 17, 2022
2b40256
Update external_captive_portal.py
denapom11 Feb 17, 2022
81a486e
Update mission_captive_portal.py
denapom11 Feb 17, 2022
74e642b
Update mission_captive_portal.py
denapom11 Feb 17, 2022
6f10592
Update mission_captive_portal.py
denapom11 Feb 17, 2022
451a717
Update mission_captive_portal.py
denapom11 Feb 17, 2022
bd84ee0
Update mission_captive_portal.py
denapom11 Feb 17, 2022
459e238
Update external_captive_portal.py
denapom11 Feb 17, 2022
d433673
Update mission_captive_portal.py
denapom11 Feb 17, 2022
807b4c7
Update mission_captive_portal.py
denapom11 Feb 17, 2022
c539cda
Update external_captive_portal.py
denapom11 Feb 17, 2022
ef0a0af
Update excapsimulator.py
denapom11 Feb 17, 2022
97872c4
Update mission_captive_portal.py
denapom11 Feb 17, 2022
1d3dc41
Update sample.js
denapom11 Apr 11, 2022
2e1a9aa
replace marker URL
shweta-palande May 13, 2022
e0283f8
beachflag doesn't work in LL2.0: reverting to blue circle
Jun 3, 2022
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
17 changes: 10 additions & 7 deletions meraki-captive-portal/external_captive_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from flask import Flask, redirect, render_template, request
from waitress import serve
import os


# Module Variables
Expand All @@ -21,16 +22,18 @@ def get_click():
global user_continue_url
global success_url

host = request.host_url
if 'DEVENV_APP_8080_URL' not in os.environ:
host = request.host_url
host = host.replace('https', 'http')
else:
host = os.environ['DEVENV_APP_8080_URL']

base_grant_url = request.args.get('base_grant_url')
user_continue_url = request.args.get('user_continue_url')
node_mac = request.args.get('node_mac')
client_ip = request.args.get('client_ip')
client_mac = request.args.get('client_mac')
success_url = host + "success"

if base_grant_url != None and base_grant_url.startswith('http://'):
base_grant_url = base_grant_url.replace("http://", "https://", 1) #hack to run excap in LL2.0
success_url = host + "/success"

return render_template(
"click.html",
Expand Down Expand Up @@ -62,6 +65,6 @@ def get_success():

# If this script is the main script being executed, start the web server.
if __name__ == "__main__":
# app.run(host="0.0.0.0", port=5004, debug=True)
serve(app, host='0.0.0.0', port=5004, url_scheme='https')
app.run(host="0.0.0.0", port=5004, debug=True)
#serve(app, host='0.0.0.0', port=5004, url_scheme='https')

9 changes: 4 additions & 5 deletions meraki-location-scanning-python/static/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
allMarkers = [], // The markers when we are in "View All" mode
lastMac = "", // The last requested MAC to follow
infoWindow = new google.maps.InfoWindow(), // The marker tooltip
markerImage = new google.maps.Marker({
icon: {
size: new google.maps.Size(15, 15),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(4.5, 4.5)}});
markerImage = new google.maps.MarkerImage('/5002/static/blue_circle.png',
new google.maps.Size(15, 15),
new google.maps.Point(0, 0),
new google.maps.Point(4.5, 4.5));

MerakiOverlay.prototype = new google.maps.OverlayView();

Expand Down
2 changes: 1 addition & 1 deletion meraki-mission-1/mxfirewallcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
teamsapi = WebexTeamsAPI(access_token=env_user.WT_ACCESS_TOKEN)

# MERAKI BASE URL
base_url = "https://api.meraki.com/api/v0"
base_url = "https://api.meraki.com/api/v1"

def getnetworklist():
orgs = ""
Expand Down
2 changes: 1 addition & 1 deletion meraki-mission-2/webhookreceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
teamsapi = WebexTeamsAPI(access_token=env_user.WT_ACCESS_TOKEN)

# MERAKI BASE URL
base_url = "http://localhost:5001"
base_url = "http://localhost:5001/api/v1"

# Flask App
app = Flask(__name__)
Expand Down
25 changes: 16 additions & 9 deletions meraki-mission-3/mission_captive_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import os
import sys
from pprint import pprint
from waitress import serve

import requests
from flask import Flask, json, redirect, render_template, request
Expand All @@ -41,10 +42,14 @@
sys.path.insert(0, project_root)
import env_user # noqa


# Module Variables
base_url = "http://localhost:5001" # Using lab simulator
captive_portal_base_url = "http://localhost:5004"
if 'DEVENV_APP_8080_URL' not in os.environ:
host = "http://localhost:8080"
else:
host = os.environ['DEVENV_APP_8080_URL']

base_url = f"{host}/api/v1" # Using lab simulator
captive_portal_base_url = f"{host}"
base_grant_url = ""
user_continue_url = ""
success_url = ""
Expand Down Expand Up @@ -111,9 +116,11 @@ def set_splash_page_settings(network_id, captive_portal_base_url):
"Content-Type": "application/json",
},
json={
"splashPage": "Click-through splash page",
"splashUrl": captive_portal_base_url + '/click',
"useCustomUrl": True
"splashPage": "Click-through splash page",
"splashUrl": captive_portal_base_url + '/click',
"useSplashUrl": True,
"redirectUrl" : "https://developer.cisco.com/meraki",
"useRedirectUrl": True
},
)
# END MISSION SECTION
Expand Down Expand Up @@ -162,14 +169,13 @@ def get_click():
global base_grant_url
global user_continue_url
global success_url

host = request.host_url

base_grant_url = request.args.get('base_grant_url')
user_continue_url = request.args.get('user_continue_url')
node_mac = request.args.get('node_mac')
client_ip = request.args.get('client_ip')
client_mac = request.args.get('client_mac')
success_url = host + "success"
success_url = captive_portal_base_url + "/success"

return render_template(
"click.html",
Expand Down Expand Up @@ -281,3 +287,4 @@ def parse_cli_args(argv):

# Start the External Captive Portal web server
app.run(host="0.0.0.0", port=5004, debug=False)
#serve(app, host='0.0.0.0', port=5004, url_scheme='https')
6 changes: 3 additions & 3 deletions meraki-mv-sense/mv_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def collect_zone_information(topic, payload):

def notify(serial_number):
# Get video link
url = "https://api.meraki.com/api/v0/networks/{1}/cameras/{0}/snapshot".format(serial_number, NETWORK_ID)
url = "https://api.meraki.com/api/v1/devices/{0}/camera/generateSnapshot".format(serial_number)

# current timestamp
# ts = str(time.time()).split(".")[0] + "000"
Expand Down Expand Up @@ -162,7 +162,7 @@ def get_network_id(network_wh):
try:
# MISSION TODO
orgs = requests.get(
"https://api.meraki.com/api/v0/organizations",
"https://api.meraki.com/api/v1/organizations",
headers={
"X-Cisco-Meraki-API-Key": env_user.MERAKI_API_KEY,
}
Expand All @@ -182,7 +182,7 @@ def get_network_id(network_wh):
try:
# MISSION TODO
networks = requests.get(
"https://api.meraki.com/api/v0/organizations/"+org["id"]+"/networks",
"https://api.meraki.com/api/v1/organizations/"+org["id"]+"/networks",
headers={
"X-Cisco-Meraki-API-Key": env_user.MERAKI_API_KEY,
})
Expand Down
48 changes: 48 additions & 0 deletions meraki-python-sdk/meraki_python_sdk_lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import meraki
import json
from pprint import pprint

# Configuration parameters and credentials for MERAKI
API_KEY = '6bec40cf957de430a6f1f2baa056b99a4fac9ea0'

client = meraki.DashboardAPI(api_key=API_KEY)
params={}


orgs = ""
try:
orgs = client.organizations.getOrganizations()
pprint(orgs)
except Exception as e:
pprint(e)

params["organization_id"] = ""
networks = ""
if orgs != "":
for org in orgs:
if org["name"] == "DevNet Sandbox":
params["organization_id"] = org["id"]
pprint(params["organization_id"])

if params["organization_id"] != "":
try:
networks = client.organizations.getOrganizationNetworks(params["organization_id"])
pprint(networks)
except Exception as e:
pprint(e)

# Now get a list of devices for that network
network_id = ""
devices = ""
if networks != "":
for network in networks:
if network["name"] == "DevNet Sandbox ALWAYS ON":
network_id = network["id"]
pprint(network_id)

if network_id != "":
try:
devices = client.networks.getNetworkDevices(network_id)
pprint(devices)
except Exception as e:
pprint(e)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## If using docker-compose
# base_url = "http://meraki_cloud_simulator:5001" # Using lab simulator
## If using stand alone
base_url = "http://localhost:5001"
base_url = "http://localhost:5001/api/v1"
captive_portal_base_url = "http://localhost:5004"
base_grant_url = ""
user_continue_url = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# MERAKI BASE URL
# if running in docker-compose base_url = "http://meraki_cloud_simulator:5001"
# if running seperately
base_url = "http://localhost:5001"
base_url = "http://localhost:5001/api/v1"

# Flask App
app = Flask(__name__)
Expand Down
6 changes: 3 additions & 3 deletions meraki_cloud_simulator/meraki_cloud_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def meraki_simulator_go():
return render_template("index.html")

# Flask micro-webservice API/URI endpoints
@merakicloudsimulator.route("/organizations", methods=["GET"])
@merakicloudsimulator.route("/api/v1/organizations", methods=["GET"])
def get_org_id():
"""Get a list of simulated organizations."""
return jsonify(ORGANIZATIONS)


@merakicloudsimulator.route("/organizations/<organization_id>/networks", methods=["GET"])
@merakicloudsimulator.route("/api/v1/organizations/<organization_id>/networks", methods=["GET"])
def get_networks(organization_id):
"""Get the list of networks for an organization."""
organization_networks = NETWORKS.get(organization_id)
Expand All @@ -39,4 +39,4 @@ def get_networks(organization_id):
)

# Start the web server
merakicloudsimulator.run(host=WEB_SERVER_BIND_IP, port=WEB_SERVER_BIND_PORT, threaded=True, debug=False)
merakicloudsimulator.run(host=WEB_SERVER_BIND_IP, port=WEB_SERVER_BIND_PORT, threaded=True, debug=False)
65 changes: 56 additions & 9 deletions meraki_cloud_simulator/merakicloudsimulator/excapsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import requests
from datetime import datetime
import os

# Module Variables
captive_portal_url = ""
Expand All @@ -24,24 +25,58 @@ def random_byte():


# Flask micro-webservice API/URI endpoints
@merakicloudsimulator.route("/networks/<network_id>/wireless/ssids/<ssid_id>", methods=["PUT"])
@merakicloudsimulator.route("/api/v1/networks/<network_id>/wireless/ssids/<ssid_id>", methods=["PUT"])
def put_ssid(network_id, ssid_id):
"""Simulate setting SSID configurations."""
print(f"Settings updated for network {network_id} ssid {ssid_id}.")
return jsonify(request.json)


@merakicloudsimulator.route(
"/networks/<network_id>/wireless/ssids/<ssid_id>/splash/settings",
"/api/v1/networks/<network_id>/wireless/ssids/<ssid_id>/splash/settings",
methods=["PUT"],
)
def put_splash(network_id, ssid_id):
global captive_portal_url
global user_continue_url
"""Simulate setting Splash Page configurations."""
print(f"Splash settings updated for network {network_id} ssid {ssid_id}.")
return jsonify(request.json)


@merakicloudsimulator.route("/networks/<network_id>/splashLoginAttempts", methods=["GET"])
new_settings = request.json
new_settings_keys = new_settings.keys()
print(new_settings_keys)


if 'DEVENV_APP_8080_URL' not in os.environ:
host = request.host_url
host = host.replace('https', 'http')
else:
host = os.environ['DEVENV_APP_8080_URL']


if "splashPage" in new_settings_keys and "splashUrl" in new_settings_keys and "redirectUrl" in new_settings_keys:
captive_portal_url = new_settings["splashUrl"]
base_grant_url = host + "/splash/grant"
user_continue_url = new_settings["redirectUrl"]
node_mac = generate_fake_mac()
client_ip = request.remote_addr
client_mac = generate_fake_mac()
splash_click_time = datetime.utcnow().isoformat()
full_url = (
captive_portal_url
+ "?base_grant_url=" + base_grant_url
+ "&user_continue_url=" + user_continue_url
+ "&node_mac=" + node_mac
+ "&client_ip=" + client_ip
+ "&client_mac=" + client_mac
)
print(captive_portal_url)
print(user_continue_url)
return jsonify(new_settings)
else:
abort(400)


@merakicloudsimulator.route("/api/v1/networks/<network_id>/splashLoginAttempts", methods=["GET"])
def get_splash_logins(network_id):
"""Get list of Splash Page logins."""
# We aren't associating specific logins with a network ID
Expand All @@ -51,16 +86,28 @@ def get_splash_logins(network_id):

@merakicloudsimulator.route("/excap", methods=["GET"])
def excap_go():
global captive_portal_url
global user_continue_url
"""Process GET requests to the /excap URI; render the index.html page."""
return render_template("excap.html")
print(captive_portal_url)
print(user_continue_url)
return render_template("excap.html", captive_portal_url = captive_portal_url, user_continue_url = user_continue_url)


@merakicloudsimulator.route("/connecttowifi", methods=["POST"])
def connect_to_wifi():
"""Save captive portal details; redirect to the External Captive Portal."""

global captive_portal_url
global user_continue_url

if 'DEVENV_APP_8080_URL' not in os.environ:
host = request.host_url
host = host.replace('https', 'http')
else:
host = os.environ['DEVENV_APP_8080_URL']

captive_portal_url = request.form["captive_portal_url"]
base_grant_url = request.host_url + "splash/grant"
base_grant_url = host + "/splash/grant"
user_continue_url = request.form["user_continue_url"]
node_mac = generate_fake_mac()
client_ip = request.remote_addr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
</div>
</div>
<div id="content">
<h1>Meraki Captive Portal Simulator</h1>
<h1>Meraki Captive Portal Simulator</h1>
<form method="POST" action="/connecttowifi">
Enter Captive Portal URL: <input name="captive_portal_url" type="text" placeholder="Fully Qualified URL" style="width: 70%"> <br><br>
Enter Post Authorization URL: <input name="user_continue_url" type="text" value="https://developer.cisco.com/meraki" tyle="width: 70%"><br><br>
Enter Captive Portal URL: <input name="captive_portal_url" type="text" placeholder="Fully Qualified URL" style="width: 70%" value="{{ captive_portal_url }}"> <br><br>
Enter Post Authorization URL: <input name="user_continue_url" type="text" placeholder="Fully Qualified URL" value="{{ user_continue_url }}" tyle="width: 70%"><br><br>
<input type="submit" value="Simulate Wifi Connection">
</form>
</div>
Expand Down
Loading