News: This forum is now permanently frozen.
Pages: [1]
Topic: Automatic Password Change  (Read 3087 times)
« on: August 19, 2007, 21:58:15 »
idrifter *
Posts: 2

Hi folks,

I'm in the middle of helping setup Monowall for a coffee shop where we wanted to be able to automagically have the password change on a daily(?) basis.  I didn't see any straight forward way to do this so I ended up writing a ruby script to do it.  Hope someone else finds it useful:

This has only been tested on 1.231.  If the web gui changes in the newer builds this might not work

Code:

require 'net/https'

class Monowall
CAPTIVE_PORTAL_UPDATE_USER = '/services_captiveportal_users_edit.php'

def initialize(user, password, address, port, use_ssl)
@user = user
@password = password
@address = address
@port = port
@use_ssl = use_ssl
end

def set_cp_password(user_id, user_name, password, user_full_name='', expiration='')
http = Net::HTTP.new(@address, @port)
http.use_ssl = @use_ssl

response = http.start do |h|
request = Net::HTTP::Post.new(CAPTIVE_PORTAL_UPDATE_USER)
request.basic_auth(@user, @password)
request.set_form_data({
'username' => user_name,
'password' => password,
'password2' => password,
'fullname' => user_full_name,
'expirationdate' => expiration,
'id' => user_id
})

h.request(request)
end

case response
when Net::HTTPFound
true
else
response.value # re-raise exception
end
end
end


# ruby is a user account that only has access to 'Services: Captive portal: Edit user'
# 192.168.123.168 is the monowall system
m = Monowall.new('ruby', '123456', '192.168.123.168', 443, true)

# guest is the account that wireless users will login with
# 0 is the internal user id associated with the account
# you can find out what the id is by clicking edit for a user and looking at the url
m.set_cp_password(0, 'guest', '123456')


I'll probably set this up as a cron job / scheduled task on another machine that plugs in a random password.
« Last Edit: August 19, 2007, 22:02:26 by idrifter »
« Reply #1 on: February 25, 2009, 13:29:33 »
kenny665 *
Posts: 1

Hi all and especially idrifter !

Thank you for your script, worked fine for me on 1.3b15 !
Very useful with a list of 100 users.


And thanks  too to the creators of m0n0wall, the great OS for embedded !

Bye !
 
Pages: [1]
 
 
Powered by SMF 1.1.20 | SMF © 2013, Simple Machines