OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Profile of FriendOfCarlotta »
  • Show Posts »
  • Messages
  • Profile Info
    • Summary
    • Show Stats
    • Show Posts...
      • Messages
      • Topics
      • Attachments

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.

  • Messages
  • Topics
  • Attachments

Messages - FriendOfCarlotta

Pages: [1]
1
German - Deutsch / Re: Route via Api erstellen
« on: May 19, 2018, 10:09:09 pm »
Danke! Problem gelöst, siehe https://forum.opnsense.org/index.php?topic=8718.msg38810#msg38810

2
Development and Code Review / Re: Add route via api
« on: May 19, 2018, 10:05:11 pm »
Thanx! The headers parameter does the trick. :-)

3
German - Deutsch / Re: Route via Api erstellen
« on: May 19, 2018, 12:55:59 pm »
Der Request ist mMn Ok:
Code: [Select]
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'}

Code: [Select]
# 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
« on: May 18, 2018, 08:07:23 pm »
Alles, was ich der response noch entlocken kann, ist:
Code: [Select]
>>> json.loads(request.text)
{'result': 'failed'}

5
Development and Code Review / Re: Add route via api
« on: May 18, 2018, 08:00:46 pm »
Ok, thanks so far. I'll check this after the holiday.  8)

6
German - Deutsch / Re: Route via Api erstellen
« on: May 18, 2018, 07:40:06 pm »
Danke für die Antwort.

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

7
Development and Code Review / Re: Add route via api
« on: May 18, 2018, 07:29:11 pm »
Thanks for the reply.

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

How do I get a more verbose response?

8
German - Deutsch / [SOLVED] Route via Api erstellen
« on: May 18, 2018, 03:19:04 pm »
Hallo!

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

Code: [Select]
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:
Code: [Select]
{'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:
Code: [Select]
{"errorMessage":"Error at /usr/local/opnsense/mvc/app/models/OPNsense/Routes/Route.php:59 - Undefined index:  (errno=8)"}

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

Payload basiert auf dem, was
Code: [Select]
/api/routes/routes/getroute ohne uuid zurückliefert.

Was läuft hier falsch?

Viele Grüße, Thomas

9
Development and Code Review / [SOLVED] Add route via api
« on: May 18, 2018, 12:57:23 pm »
Hello!

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

Code: [Select]
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
Code: [Select]
{'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:
Code: [Select]
{"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
Code: [Select]
/api/routes/routes/setroute/<uuid> with the same payload.

The payload has been received with
Code: [Select]
getroute and was modified accordingly.

Any hints are appreciated.

Regards, Thomas

10
German - Deutsch / Re: Proxy-Authentifizierung gegen Samba 4 AD
« on: August 11, 2017, 11:24:45 am »
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
17.7 Legacy Series / Re: proxy authentication against a Samba 4 AD
« on: August 11, 2017, 11:19:16 am »
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
17.7 Legacy Series / [SOLVED] proxy authentication against a Samba 4 AD
« on: August 10, 2017, 03:30:31 pm »
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
German - Deutsch / [SOLVED] Proxy-Authentifizierung gegen Samba 4 AD
« on: August 10, 2017, 03:23:31 pm »
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

Pages: [1]
OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2