Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - FriendOfCarlotta

#2
Thanx! The headers parameter does the trick. :-)
#3
German - Deutsch / Re: Route via Api erstellen
May 19, 2018, 12:55:59 PM
Der Request ist mMn Ok:

import json
import requests

apikey = 'xxx'
apisecret = 'xxx'
url = 'https://10.0.0.254/api/routes/routes/addroute'
payload = '{"route":{"descr":"vlan40","disabled":"0","gateway":"VLAN_GW","network":"10.0.40.0/24"}}'
res = requests.post(url, data=payload, verify=None, auth=(apikey, apisecret))
print(res)
print(json.loads(res.text))

<Response [200]>
{'result': 'failed'}



# cat /tmp/gateway_list.json
{"WAN_DHCP":"WAN_DHCP - 192.168.107.2","VLAN_GW":"VLAN_GW - 10.0.0.253","Null4":"Null4 - 127.0.0.1","Null6":"Null6 - ::1"}


Entspricht dem Wiki-Beispiel und verwendet die von dir vorgeschlagene Payload-Struktur.
Die so von Hand im Ui angelegte Route funktioniert.

Was mache ich da falsch? Kann man der Api nicht entlocken, welches Element der Datenstruktur ihr Schluckauf bereitet?
#4
German - Deutsch / Re: Route via Api erstellen
May 18, 2018, 08:07:23 PM
Alles, was ich der response noch entlocken kann, ist:

>>> json.loads(request.text)
{'result': 'failed'}
#5
Ok, thanks so far. I'll check this after the holiday.  8)
#6
German - Deutsch / Re: Route via Api erstellen
May 18, 2018, 07:40:06 PM
Danke für die Antwort.

Wenn ich also z.B.
payload = '{"route":  {"descr": "vlan40", "disabled": "0", "gateway" : "VLAN_GW", "network": "10.0.40.0/24"}}' verwende, bekomme ich nur <Response [200]> zurück. Nichts weiter. Route wird nicht angelegt.
Das Gateway 'VLAN_GW' funktioniert mit per Ui angelegten Routen problemlos.
#7
Thanks for the reply.

In fact I tried this syntax already. But I only get <Response [200]> as feedback and the route does not show up in the ui.  :-\

How do I get a more verbose response?
#8
Hallo!

Ich möchte eine Route via Api mit Python 3 und requests erstellen:


apikey = 'xxx'
apisecret = 'xxx'
url = 'https://10.0.0.254/api/routes/routes/addroute'
requests.post(url, data=payload, verify=None, auth=(apikey, apisecret))


Payload sieht so aus:

{'route': {'network': '10.0.50.0/24', 'gateway': {'Null4': {'value': 'Null4 - 127.0.0.1', 'selected': 0}, 'Null6': {'value': 'Null6 - ::1', 'selected': 0}, 'VLAN_GW': {'value': 'VLAN_GW - 10.0.0.253', 'selected': 1}, 'WAN_DHCP': {'value': 'WAN_DHCP - 192.168.107.2', 'selected': 0}}, 'descr': 'vlan50', 'disabled': '0'}}


Der Post-Request liefert diese Fehlermeldung zurück:

{"errorMessage":"Error at /usr/local/opnsense/mvc/app/models/OPNsense/Routes/Route.php:59 - Undefined index:  (errno=8)"}


Andererseits kann ich via /api/routes/routes/setroute/<uuid> mit dem identischen Payload eine existierende Route erfolgreich ändern.

Payload basiert auf dem, was /api/routes/routes/getroute ohne uuid zurückliefert.

Was läuft hier falsch?

Viele Grüße, Thomas
#9
Hello!

I try to add a new route via the api using Python 3 and requests:


apikey = 'xxx'
apisecret = 'xxx'
url = 'https://10.0.0.254/api/routes/routes/addroute'
requests.post(url, data=payload, verify=None, auth=(apikey, apisecret))


payload is

{'route': {'network': '10.0.50.0/24', 'gateway': {'Null4': {'value': 'Null4 - 127.0.0.1', 'selected': 0}, 'Null6': {'value': 'Null6 - ::1', 'selected': 0}, 'VLAN_GW': {'value': 'VLAN_GW - 10.0.0.253', 'selected': 1}, 'WAN_DHCP': {'value': 'WAN_DHCP - 192.168.107.2', 'selected': 0}}, 'descr': 'vlan50', 'disabled': '0'}}


As result I receive:

{"errorMessage":"Error at /usr/local/opnsense/mvc/app/models/OPNsense/Routes/Route.php:59 - Undefined index:  (errno=8)"}


On the other side I am able to change an existing route via /api/routes/routes/setroute/<uuid> with the same payload.

The payload has been received with getroute and was modified accordingly.

Any hints are appreciated.

Regards, Thomas
#10
Hallo!

Scheint ein Browserproblem zu sein. Das Ganze funktioniert, wenn man den Proxy in den Systemeinstellungen des Betriebssystems einträgt und den Browser dann die Proxyeinstellungen des Systems nutzen lässt. Funktioniert so unter Linux & Windows.

Thomas
#11
Hi!

It's a browser issue. Don't use the browser proxy settings! Configure the proxy in the system settings of the os (works for Linux and Windows) and tell the browser to use the system settings. Works now like a charm!

Thomas
#12
Hello!

Does proxy authentication against a samba 4 AD work at least?

I have successfully set up the LDAP access on a 17.7 test system:
* imported ca.pem of the samba server.
* port 636 and ssl configured.
* bind credentials work.
* authentication container queried and selected.
* servername of the AD server is resolvable via DNS.
* AD users can be successfully authenticated with  System | Access | Tester.

So far so good. But if I try to log in on the proxy with the client browser I get a loop. After the user data has been entered, the empty login dialog appears again and again.
The system log file shows:
Squid: LDAP bind error (Can not contact LDAP server)
Squid: user 'username' could not authenticate.

Why can squid not query the AD, but the OPNsense web interface very well?

Regards, Thomas
#13
Hallo!

Funktioniert die Proxy-Authentifizierung gegen einen Samba 4 AD grundsätzlich?

Ich habe hier auf einem 17.7-Testsystem den Zugangsserver vom Typ LDAP erfolgreich eingerichtet:
* ca.pem des Samba-Servers importiert.
* Port 636 und SSL konfiguriert.
* Bind-Zugangsdaten eingetragen.
* Authentifizierungscontainer abgefragt und ausgewählt.
* servername des AD-Servers ist per DNS auflösbar.
* AD-User lassen sich unter System|Zugang|Prüfer erfolgreich authentifizieren.

Soweit so gut. Aber auf einem Client-Browser lande ich beim Anmelden auf dem Proxy in einer Schleife. Nach dem Eintragen der Userdaten erscheint wieder der leere Anmeldedialog.
Die System-Logdatei zeigt:
squid: LDAP bind error (Can't contact LDAP server)
squid: user 'username' could not authenticate.

Warum kann squid den LDAP nicht abfragen, das OPNsense-Webinterface aber sehr wohl?

Grüße, Thomas