<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>pyrad – RADIUS for Python — pyrad 1.2 documentation</title> <link rel="stylesheet" href="_static/repoze.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '1.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="pyrad 1.2 documentation" href="#" /> <link rel="next" title="pyrad.client – basic client" href="api/client.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="api/client.html" title="pyrad.client – basic client" accesskey="N">next</a> |</li> <li><a href="#">pyrad 1.2 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="pyrad-radius-for-python"> <span id="index"></span><h1><a class="reference internal" href="#module-pyrad" title="pyrad"><tt class="xref py py-mod docutils literal"><span class="pre">pyrad</span></tt></a> – RADIUS for Python<a class="headerlink" href="#pyrad-radius-for-python" title="Permalink to this headline">¶</a></h1> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Author:</th><td class="field-body">Wichert Akkerman</td> </tr> <tr class="field-even field"><th class="field-name">Version:</th><td class="field-body">1.2</td> </tr> </tbody> </table> <span class="target" id="module-pyrad"></span><div class="section" id="introduction"> <h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2> <p>pyrad is an implementation of a RADIUS client as described in RFC2865. It takes care of all the details like building RADIUS packets, sending them and decoding responses.</p> <p>Here is an example of doing a authentication request:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pyrad.packet</span> <span class="kn">from</span> <span class="nn">pyrad.client</span> <span class="kn">import</span> <span class="n">Client</span> <span class="kn">from</span> <span class="nn">pyrad.dictionary</span> <span class="kn">import</span> <span class="n">Dictionary</span> <span class="n">srv</span><span class="o">=</span><span class="n">Client</span><span class="p">(</span><span class="n">server</span><span class="o">=</span><span class="s">"radius.my.domain"</span><span class="p">,</span> <span class="n">secret</span><span class="o">=</span><span class="s">"s3cr3t"</span><span class="p">,</span> <span class="nb">dict</span><span class="o">=</span><span class="n">Dictionary</span><span class="p">(</span><span class="s">"dicts/dictionary"</span><span class="p">,</span> <span class="s">"dictionary.acc"</span><span class="p">))</span> <span class="n">req</span><span class="o">=</span><span class="n">srv</span><span class="o">.</span><span class="n">CreateAuthPacket</span><span class="p">(</span><span class="n">code</span><span class="o">=</span><span class="n">pyrad</span><span class="o">.</span><span class="n">packet</span><span class="o">.</span><span class="n">AccessRequest</span><span class="p">,</span> <span class="n">User_Name</span><span class="o">=</span><span class="s">"wichert"</span><span class="p">,</span> <span class="n">NAS_Identifier</span><span class="o">=</span><span class="s">"localhost"</span><span class="p">)</span> <span class="n">req</span><span class="p">[</span><span class="s">"User-Password"</span><span class="p">]</span><span class="o">=</span><span class="n">req</span><span class="o">.</span><span class="n">PwCrypt</span><span class="p">(</span><span class="s">"password"</span><span class="p">)</span> <span class="n">reply</span><span class="o">=</span><span class="n">srv</span><span class="o">.</span><span class="n">SendPacket</span><span class="p">(</span><span class="n">req</span><span class="p">)</span> <span class="k">if</span> <span class="n">reply</span><span class="o">.</span><span class="n">code</span><span class="o">==</span><span class="n">pyrad</span><span class="o">.</span><span class="n">packet</span><span class="o">.</span><span class="n">AccessAccept</span><span class="p">:</span> <span class="k">print</span> <span class="s">"access accepted"</span> <span class="k">else</span><span class="p">:</span> <span class="k">print</span> <span class="s">"access denied"</span> <span class="k">print</span> <span class="s">"Attributes returned by server:"</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">reply</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span> <span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">reply</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> </pre></div> </div> </div> <div class="section" id="requirements-installation"> <h2>Requirements & Installation<a class="headerlink" href="#requirements-installation" title="Permalink to this headline">¶</a></h2> <p>pyrad requires Python 2.6 or later, or Python 3.2 or later</p> <p>Installing is simple; pyrad uses the standard distutils system for installing Python modules:</p> <div class="highlight-python"><pre>python setup.py install</pre> </div> </div> <div class="section" id="api-documentation"> <h2>API Documentation<a class="headerlink" href="#api-documentation" title="Permalink to this headline">¶</a></h2> <p>Per-module <a class="reference internal" href="#module-pyrad" title="pyrad"><tt class="xref py py-mod docutils literal"><span class="pre">pyrad</span></tt></a> API documentation.</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="api/client.html"><tt class="docutils literal"><span class="pre">pyrad.client</span></tt> – basic client</a></li> <li class="toctree-l1"><a class="reference internal" href="api/dictionary.html"><tt class="docutils literal"><span class="pre">pyrad.dictionary</span></tt> – RADIUS dictionary</a></li> <li class="toctree-l1"><a class="reference internal" href="api/host.html"><tt class="docutils literal"><span class="pre">pyrad.host</span></tt> – RADIUS host definition</a></li> <li class="toctree-l1"><a class="reference internal" href="api/packet.html"><tt class="docutils literal"><span class="pre">pyrad.packet</span></tt> – packet encoding and decoding</a><ul> <li class="toctree-l2"><a class="reference internal" href="api/packet.html#constants">Constants</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="api/proxy.html"><tt class="docutils literal"><span class="pre">pyrad.proxy</span></tt> – basic proxy</a></li> <li class="toctree-l1"><a class="reference internal" href="api/server.html"><tt class="docutils literal"><span class="pre">pyrad.server</span></tt> – basic server</a></li> </ul> </div> <div class="section" id="indices-and-tables"> <h3>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li><a class="reference internal" href="genindex.html"><em>Index</em></a></li> <li><a class="reference internal" href="py-modindex.html"><em>Module Index</em></a></li> <li><a class="reference internal" href="search.html"><em>Search Page</em></a></li> </ul> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <p class="logo"><a href="#"> <img class="logo" src="_static/logo.png" alt="Logo"/> </a></p> <h3><a href="#">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">pyrad</span></tt> – RADIUS for Python</a><ul> <li><a class="reference internal" href="#introduction">Introduction</a></li> <li><a class="reference internal" href="#requirements-installation">Requirements & Installation</a></li> <li><a class="reference internal" href="#api-documentation">API Documentation</a><ul> <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li> </ul> </li> </ul> </li> </ul> <h4>Next topic</h4> <p class="topless"><a href="api/client.html" title="next chapter"><tt class="docutils literal docutils literal docutils literal"><span class="pre">pyrad.client</span></tt> – basic client</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/index.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="api/client.html" title="pyrad.client – basic client" >next</a> |</li> <li><a href="#">pyrad 1.2 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2002-2009 Wichert Akkerman, 2009 Kristoffer Gronlund. Last updated on Sep 05, 2013. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>