aruba central apis · 2.allow only @gmail.com, @outlook.comand @hotmail.comusers with string...

53
Aruba Central APIs Adolfo Bolivar April 2018

Upload: others

Post on 30-May-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

ArubaCentralAPIsAdolfoBolivarApril2018

Page 2: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Agenda

• Why APIs?• Enabling ArubaCentraltosupport APIs• GettingtheAccesstokenandrefreshtokenviaAPIs• ArubaCentralAPIs – Demos:• 1.Proactive notifications• 2.GuestAccess- sessionstrack

Page 3: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

http://community.arubanetworks.com/t5/Atmosphere-2017/Moving-beyond-CLI-A-Beginners-Guide-to-Network-Automation-and/gpm-p/297667

Page 4: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc
Page 5: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc
Page 6: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

HumanReadable

WhatisanAPI(ApplicationProgrammingInterface)

MachineReadableCentral

Page 7: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

EntryPointtoAPIrequestsSecurity–>Threatprotection

APIGateway Central

Page 8: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

{REST}API

Page 9: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

RESTAPI

v RESTisanAPIthatallowsclientstoperformread/writeoperations.

v RESTusesHTTPtoperformasetofactions:

• “Create”-->Post

• “Read”--> Get

• “Update”--> Put

• “Delete”--> Delete

Page 10: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

RESTAPI

Page 11: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

WhatisJSON?

– { “key” : “value” }

– { “key 1” : “value 1”, “key 2” : “value 2” }

– { "name": "John", "age": 30, "car": null }

– {"name": "John","age": 30,"cars": [ "Ford", "BMW", "Fiat" ]}

Page 12: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Overview– APICall

GetRequest+AccessToken

200OKResponseCode+DatainJSONformat

ValidateAccessToken

ValidateAccessToken

OAUTH2.0ImplementationtogetAccessToken

PostRequest+DatainJSONformat+AccessToken

200OKResponseCode+DatainJSONformat

HTTPS

ApplicationHTTPClient

CentralAPIGWHTTPServer

Page 13: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

EnablingArubaCentraltosupportAPIs

Page 14: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

OpenacasewithTACsupportandrequesttoenableAPIGateway

Page 15: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

InternalAddress– Employees&TAConly

Page 16: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Authorizeanewapplication

Page 17: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Newapplication:Postman

Page 18: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Newapplication:Postman

"client_id": clientid"client_secret": clientsecret

Page 19: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

WhatisanAccessToken?

AccessToken:stringrepresentinganaccessauthorizationissuedtotheclient,ratherthanusingtheresourceowner'scredentialsdirectly.

Page 20: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

ViewingAccessToken

Access token expires in 7200seg/120min/2hrs

Page 21: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

WhatisaRefreshToken?

RefreshToken:specialkindoftokenthatcanbeusedtoobtainarenewedaccesstoken.Refreshtokensmustbestoredsecurelybyanapplicationbecausetheyessentiallyallowausertoremainauthenticatedforever.

Page 22: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

GettinganewAccessToken

https://internal-apigw.central.arubanetworks.com/oauth2/token

params = {"client_id": clientid,"client_secret": clientsecret, "grant_type": "refresh_token","refresh_token": refresh_token }

Page 23: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

NewAccessandRefreshTokens–>AnswerfromCentral

Page 24: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

GettingtheAccesstokenandrefreshtokenviaAPIs

Page 25: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Creating a“gmail”admin account

From SEEL - ArubaCentral setup (Internal users)1.Allow all @arubanetworks.com and @hpe.com users.2.Allow only @gmail.com, @outlook.com and @hotmail.com users with string "centraldemo" in the id; e.g., [email protected], [email protected] etc.

Page 26: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

“gmail”admin account addedtoCentral

Page 27: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Confirmation emailfrom Central

Page 28: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Get the CSRFtoken

https://internal-apigw.central.arubanetworks.com/oauth2/authorize/central/api/login

{"username":"[email protected]","password":”XXXXXXX”}

Page 29: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Get the CSRFtoken ->Answer from Central

Session - Cookie: “d6f95f91ab713556_5acccc70.kkwkBXXXXXXXXX” CSRF token: "##8a8aa936d43dXXXXXXXX"

Page 30: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Get the Auth token

https://internal-apigw.central.arubanetworks.com/oauth2/authorize/central/api

{ "customer_id": "500XXXX"}

Page 31: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Get the Auth token ->Answer from Central

Code: “990WpoaPMQbVXXXXX”

Page 32: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Get the Accesstoken andRefreh token

https://internal-apigw.central.arubanetworks.com/oauth2/token

Page 33: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Get the Accesstoken andRefreh token ->Answer from Central

Page 34: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Task:Eachtimeavirtualcontrollerisdisconnectedfor+10min,notifyviaWebhook

Page 35: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

List Notifications supported by Central

https://internal-apigw.central.arubanetworks.com/central/v1/notifications/types

Page 36: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

List Notifications –> Answer from Central

{"name":"Virtualcontrollerdisconnected"},

Page 37: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

List Webhooks

https://internal-apigw.central.arubanetworks.com/central/v1/webhooks

AnswerfromCentral

Page 38: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Create Webhook trigger inBuilt.io

Page 39: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Add awebhook

https://internal-apigw.central.arubanetworks.com/central/v1/webhooks

{"name":"Built.io Webhook","urls":["https://runflow.built.io/run/VuXXXXXXX"]}

Page 40: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Add awebhook –> Answer from Central

"wid": "0d7b375a-5885-4e1a-89e6-e4XXXXXXXX"

Page 41: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Enable "Virtualcontroller disconnected”notification/Alertandpoint it toWebhook

https://internal-apigw.central.arubanetworks.com/central/v1/notifications/settings

{"type":"Virtualcontrollerdisconnected","rules":[{"severity":"Critical","delivery_options":["Webhook"],"emails":[],"webhooks":["0d7b375a-5885-4e1a-89e6-e4875f760f38"],"group":[],"label":[],"device_id":[],"duration":10,"value":"string"}],"active":true}

Page 42: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Enable "Virtualcontroller disconnected”notification/Alertandpoint it toWebhook –> Answer from Central

Page 43: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Check the notification/Alert –> Answer from Central

https://internal-apigw.central.arubanetworks.com/central/v1/notifications/settings

Page 44: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Disconnect VirtualController –> After 10minutes

https://internal-apigw.central.arubanetworks.com/central/v1/notifications

AnswerfromCentral

Page 45: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Disconnect VirtualController –> After 10minutes–> Built.io log

Page 46: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Task:GuestAccess-sessionstracking

Page 47: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Check Guest Portals available

https://internal-apigw.central.arubanetworks.com/guest/v1/portals

Page 48: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Guest Portals ->Answer from ArubaCentral

“Demo Captive Portal” : Guest portal ID

Page 49: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Check the sessions associated tothe GuestPortal

https://internal-apigw.central.arubanetworks.com/guest/v1/portals/59bef48b-9d10-472b-aa73-181c8d4ebea0/sessions?access_token=yerXIVLaXXjzSPPxMV7qN2jJbEWpoFP8&ssid_name=Guest&offset=0&sort=%2Baccount_name&limit=100

https://internal-apigw.central.arubanetworks.com/guest/v1//portals/{portal_id}/sessions

Page 50: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Check the sessions associated tothe GuestPortal->Answer from Central

Page 51: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Guest:login dateandtime

“login_at” parameter is in epoch time format https://www.epochconverter.com/

Python script to convert the epoch time format to human readable:

https://www.systutorials.com/241698/how-to-convert-epoch-timestamp-to-human-readable-date-format-in-python/

Page 52: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

Thanks

Page 53: Aruba Central APIs · 2.Allow only @gmail.com, @outlook.comand @hotmail.comusers with string "centraldemo" in the id; e.g., user+centraldemo@gmail.com, mycentraldemoid@hotmail.cometc

References

http://community.arubanetworks.com/t5/Atmosphere-2017/Moving-beyond-CLI-A-Beginners-Guide-to-Network-Automation-and/gpm-p/297667

https://arubapedia.arubanetworks.com/arubapedia/index.php/Category:Aruba_Central_TME#API_Basics

https://tools.ietf.org/html/rfc6750 (Oauth 2.0RFC)

http://community.arubanetworks.com/t5/Network-Management/Aruba-Central-API-Gateway-a-report-with-the-list-of-APs-and/m-p/312606