Graf commitů

12 commitů

Autor SHA1 Zpráva Datum
Jo-Philipp Wich
766643fcf1 luci-mod-rpc: drop "secret" value from rpc session objects
Drop the "secret" value from RPC session objects in order to make them
compatible with ordinary web sessions used by the LuCI web interface.

That secret value was never used for anything and is the only difference
compared to normal LuCI login sessions.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-01-30 16:51:49 +01:00
Jo-Philipp Wich
364c271a84 luci-mod-rpc: fix unresolved controller reference in rpc_auth()
Fixes the following error:

   .../rpc.lua:85: attempt to index global 'ctrl' (a nil value)

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-18 16:58:17 +02:00
Jo-Philipp Wich
055b621cf5 luci-mod-rpc: more auth/login fixes, expose further libraries
The previous attempt to fix authentication broke login functionality so
rework the code once again, this time with referencing helper functions
directly via the controller scope.

Furthermore, properly expose luci.sys.wifi.getiwinfo() and luci.ip.

For getiwinfo(), the RPC wrapped function accepts one further optional
parameter specifying the operation to invoke on the iwinfo instance.
If no operation is specified, a summary object containing all info
without country and scan list is returned.

Example to obtain iwinfo summary object:
  curl --cookie sysauth=... \
       --data '{"method": "wifi.getiwinfo", "params": ["wlan0"]}' \
		"http://192.168.1.1/cgi-bin/luci/rpc/sys"

Example to obtain iwinfo scan list:
  curl --cookie sysauth=... \
       --data '{"method": "wifi.getiwinfo", "params": ["wlan0", "scanlist"]}' \
		"http://192.168.1.1/cgi-bin/luci/rpc/sys"

The exposed luci.ip class uses a similar approach to allow invoking
instance methods on cidr objects. The new(), IPv4(), IPv6() and MAC()
constructors accept two further optional arguments, with the first
specifying the instance method to invoke and the second the value to
pass to the instance method.

Example to get list of IPv4 neighbours (ARP entries):
  curl --cookie sysauth=... \
       --data '{"method": "neighbors", "params": [{"family": 4}]}' \
		"http://192.168.1.1/cgi-bin/luci/rpc/ip"

Example to add 100 hosts to a network address:
  curl --cookie sysauth=... \
       --data '{"method": "IPv4", "params": ["192.168.0.1", "255.255.255.0", "add", 1000]}' \
		"http://192.168.1.1/cgi-bin/luci/rpc/ip"

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 23:11:07 +02:00
Jo-Philipp Wich
6a1cdca345 luci-mod-rpc: fix authentication via query string parameter
Localize the `authenticatior()` and `session_retrieve()` functions into the
`index()` function scope so that they're retained when extracting the
function into the dispatcher bytecode cache.

Also allow access to the global scope since upvalues do not work reliably
due to the out-of-context byte code caching of index functions.

Fixes https://github.com/openwrt/luci/issues/1300#issuecomment-381352765
Fixes feefc600e ("luci-mod-rpc: rework authentication and session handling")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 19:56:26 +02:00
Jo-Philipp Wich
feefc600ed luci-mod-rpc: rework authentication and session handling
- Use the ubus session.login procedure to authenticate credentials
 - Fix testing of allowed usernames
 - Support authentication via sysauth cookie

Fixes #1300, #1700, #1711

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06 07:56:56 +02:00
Sabbir Ahmed
fff7c6c518 modules/luci-mod-rpc: fix attempt to index global 'luci' (a nil value) 2015-09-12 15:11:18 +06:00
Jo-Philipp Wich
3610f3222d luci-mod-rpc: move luci config require into the authentication function (#427)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-07-15 23:28:16 +02:00
Jo-Philipp Wich
16047d03c5 luci-mod-rpc: add missing luci config require
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-07-15 22:30:45 +02:00
Jo-Philipp Wich
41d2b33087 Update my email addresses in the license headers
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-16 23:49:44 +01:00
Jo-Philipp Wich
7a3493b1f7 Globally reduce copyright headers
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-16 23:38:38 +01:00
Jo-Philipp Wich
199c8cbc4c luci-base: switch to ubus sessions
Remove luci.sauth session storage implementation and offload the session
management to the rpcd ubus backend. Also depend on rpcd due to this.
2015-01-15 11:09:05 +01:00
Jo-Philipp Wich
1bb4822dca Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
 * Make each LuCI module its own standalone package
 * Deploy a shared luci.mk which is used by each module Makefile

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:26:20 +01:00
Přejmenováno z modules/rpc/luasrc/controller/rpc.lua (Procházet dále)