pythongssapi / gssapi-console

An interactive tool for testing Python GSSAPI programs
ISC License
0 stars 0 forks source link

Feature: Ipython console #2

Open erinn opened 6 years ago

erinn commented 6 years ago

I don't know how easy or reasonable this request would be, and maybe at some point I can look into doing it myself, but would it be possible to have ipython for the interactive session? Gives command completion, history and all kinds of other goodness.

Thanks for the project, will be using it extensively soon.

DirectXMan12 commented 6 years ago

I'm not an IPython user, and probably won't have time to add support myself, but I'd accept a PR that keeps things well-separated. FWIW, the current gssapi-console does have completion and history support, but I do get the appeal of IPython.

The internals of gssapi-console are actually relatively simple -- most of the hard work is done by k5test and Python's built-in REPL library (code.InteractiveConsole).

Basically, gssapi-console does the following (not including the yalpt driver):

  1. accept a "driver" (currently only the krb5 driver exists)
  2. ask the driver to set up a realm if one wasn't passed in (calls out to k5test)
  3. "attach" to the realm (calls out to k5test)
  4. setup up the REALM local to point to the realm configuration object
  5. print a useful banner
  6. import gssapi and gssapi.raw as gb
  7. launch into the main REPL (just calls out to code.InteractiveConsole currently)

You can look at core.py and drivers.py for more details

erinn commented 6 years ago

As a very, very quick and dirty way, run gssapi-console, then the following:

from IPython import embed
embed()

Anyway continuing to look at how to put this together.