#!/usr/bin/env python #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE #------------------------------------------------------------------------------ # # This is a radius test script. # You need to install the python-pyrad package and python-six package for it to work. # It also needs the file named dictionary in the same directory as the script. # # Set the Radius servers in radsvrs below # Set the shared secret # Pass in the user name as a parameter and the password from stdin. import sys from pyrad.client import Client from pyrad.dictionary import Dictionary import pyrad.packet radsvrs = ["server1", "server2", "server3"] sharedsecret = b"your_shared_secret" user=sys.argv password = sys.stdin.read().strip() for radsvr in radsvrs: srv = Client(server=radsvr, secret=sharedsecret, dict=Dictionary("dictionary")) # create request req = srv.CreateAuthPacket(code=pyrad.packet.AccessRequest, User_Name=user, NAS_Identifier="localhost") req["User-Password"] = req.PwCrypt(password) # send request reply = srv.SendPacket(req) if reply.code == pyrad.packet.AccessAccept: print("access accepted") sys.exit(0) print("access denied") print("Attributes returned by server:") for i in reply.keys(): print("%s: %s\n" % (i, reply[i]))
This is Tom's change:
Introduced new 'Unsupported' directory to clarify that some files
in the SDP are not officially supported. These files are samples for
illustration, to provide examples, or are deprecated but not yet
ready for removal from the package.
The Maintenance and many SDP triggers have been moved under here,
along with other SDP scripts and triggers.
Added comments to p4_vars indicating that it should not be edited
directly. Added reference to an optional site_global_vars file that,
if it exists, will be sourced to provide global user settings
without needing to edit p4_vars.
As an exception to the refactoring, the totalusers.py Maintenance
script will be moved to indicate that it is supported.
Removed settings to support long-sunset P4Web from supported structure.
Structure under new .../Unsupported folder is:
Samples/bin Sample scripts.
Samples/triggers Sample trigger scripts.
Samples/triggers/tests Sample trigger script tests.
Samples/broker Sample broker filter scripts.
Deprecated/triggers Deprecated triggers.
To Do in a subsequent change: Make corresponding doc changes.
Two factor authentication scripts that use Radius authentication via pyrad.
Since this is using Radius, it should work against most 2FA systems. It has been
tested against RSA SecureID.