mirror of
https://github.com/Yubico/yubiadmin.git
synced 2025-02-22 11:54:16 +01:00
Add command line arguments to yubiadmin script.
This commit is contained in:
parent
fcfc2d5626
commit
34b5cc10f4
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import base64
|
import base64
|
||||||
|
import argparse
|
||||||
from wsgiref.simple_server import make_server
|
from wsgiref.simple_server import make_server
|
||||||
from webob.dec import wsgify
|
from webob.dec import wsgify
|
||||||
from webob import exc
|
from webob import exc
|
||||||
@ -14,7 +15,22 @@ STATIC_ASSETS = ['js', 'css', 'img', 'favicon.ico']
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# TODO: Take command line args to set port.
|
parser = argparse.ArgumentParser(
|
||||||
|
description="",
|
||||||
|
add_help=True,
|
||||||
|
# formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||||
|
)
|
||||||
|
parser.add_argument('--interface', nargs='?', default=settings['iface'],
|
||||||
|
help='Listening interface')
|
||||||
|
parser.add_argument('--port', nargs='?', default=settings['port'],
|
||||||
|
help='Listening port')
|
||||||
|
parser.add_argument('--username', nargs='?', default=settings['user'],
|
||||||
|
help='Username for authentication')
|
||||||
|
parser.add_argument('--password', nargs='?', default=settings['pass'],
|
||||||
|
help='Password for authentication')
|
||||||
|
args = parser.parse_args()
|
||||||
|
args.port = int(args.port)
|
||||||
|
|
||||||
mod_dir = os.path.dirname(server.__file__)
|
mod_dir = os.path.dirname(server.__file__)
|
||||||
base_dir = os.path.abspath(os.path.join(mod_dir))
|
base_dir = os.path.abspath(os.path.join(mod_dir))
|
||||||
static_dir = os.path.join(base_dir, 'static')
|
static_dir = os.path.join(base_dir, 'static')
|
||||||
@ -26,17 +42,17 @@ if __name__ == '__main__':
|
|||||||
def with_static(request):
|
def with_static(request):
|
||||||
if request.authorization:
|
if request.authorization:
|
||||||
_, auth = request.authorization
|
_, auth = request.authorization
|
||||||
if base64.b64decode(auth) == '%s:%s' % (settings['user'],
|
if base64.b64decode(auth) == '%s:%s' % (args.username,
|
||||||
settings['pass']):
|
args.password):
|
||||||
base = request.path_info_peek()
|
base = request.path_info_peek()
|
||||||
if base in STATIC_ASSETS:
|
if base in STATIC_ASSETS:
|
||||||
return request.get_response(static_app)
|
return request.get_response(static_app)
|
||||||
return request.get_response(server.application)
|
return request.get_response(server.application)
|
||||||
|
|
||||||
#Deny access
|
# Deny access
|
||||||
response = exc.HTTPUnauthorized()
|
response = exc.HTTPUnauthorized()
|
||||||
response.www_authenticate = ('Basic', {'realm': REALM})
|
response.www_authenticate = ('Basic', {'realm': REALM})
|
||||||
return response
|
return response
|
||||||
|
|
||||||
httpd = make_server(settings['iface'], settings['port'], with_static)
|
httpd = make_server(args.interface, args.port, with_static)
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
@ -35,14 +35,25 @@
|
|||||||
yubiadmin - Web interface for configuring Yubico software components.
|
yubiadmin - Web interface for configuring Yubico software components.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B yubiadmin
|
.B yubiadmin
|
||||||
|
[\fI--help\fR] [\fI--interface INTERFACE\fR] [\fI--port PORT\fR] [\fI--username USERNAME] [\fI--password PASSWORD]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Runs the YubiAdmin web server. To be able to read and write the various
|
Runs the YubiAdmin web server. To be able to read and write the various
|
||||||
configuration files that the YubiAdmin server exposes, the server is intended
|
configuration files that the YubiAdmin server exposes, the server is intended
|
||||||
to be run as root. By default the server can be accessed by pointing a web
|
to be run as root. By default the server can be accessed by pointing a web
|
||||||
browser to http://localhost:8080/ on the machine which is running the server,
|
browser to http://localhost:8080/ on the machine which is running the server,
|
||||||
using the username: "yubiadmin" and the password: "yubiadmin". These settings
|
using the username: "yubiadmin" and the password: "yubiadmin". These settings
|
||||||
and many more are available by editing the configuration file.
|
and many more are available by editing the configuration file, or by using the
|
||||||
|
program arguments.
|
||||||
|
.HP
|
||||||
|
\fB\-\-interface\fR Network interface to listen to.
|
||||||
|
.HP
|
||||||
|
\fB\-\-port\fR IP port to listen to.
|
||||||
|
.HP
|
||||||
|
\fB\-\-username\fR Username to use for authentication.
|
||||||
|
.HP
|
||||||
|
\fB\-\-password\fR Password to use for authentication.
|
||||||
|
.PP
|
||||||
Configuration is read from /etc/yubico/admin/yubiadmin.conf
|
Configuration is read from /etc/yubico/admin/yubiadmin.conf
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Report yubiadmin bugs in
|
Report yubiadmin bugs in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user