f41b982009-05-07Martin Stjernholm // This is a roxen module. Copyright © 2009, Roxen IS.
91a9562004-05-14Marcus Wellhardh // #include <module.h> inherit "module";
84aee52015-10-23Henrik Grubbström (Grubba) constant cvs_version = "$Id$";
91a9562004-05-14Marcus Wellhardh constant thread_safe = 1; constant module_type = MODULE_TAG;
4acc0a2004-06-09Jonas Wallden constant module_name = "Tags: Support for Kerberos authentication"; constant module_doc = ("Adds a couple of tags to enable simple Kerberos "
91a9562004-05-14Marcus Wellhardh  "authentication."); constant module_unique = 1;
d592af2004-05-14Marcus Wellhardh #if constant(Kerberos.Context)
4acc0a2004-06-09Jonas Wallden Kerberos.Context ctx; string instantiate_msg;
91a9562004-05-14Marcus Wellhardh  class TagIfKerberosAuth { inherit RXML.Tag; constant name = "if"; constant plugin_name = "kerberos-auth"; int eval(string user, RequestID id, mapping args) {
4acc0a2004-06-09Jonas Wallden  if (!ctx) RXML.run_error("The Kerberos module is not active.\n");
91a9562004-05-14Marcus Wellhardh  if(!args->password) RXML.parse_error("No password attribute specified.\n"); NOCACHE(); return ctx->authenticate(user, args->password); } }
4acc0a2004-06-09Jonas Wallden void start() { if (mixed err = catch { // This may throw an error if Kerberos support is included in Pike // but a run-time error takes place. ctx = ctx || Kerberos.Context(); }) { // Save error message for status() instantiate_msg = "An error occurred when enabling the Kerberos module.\n"; #ifdef DEBUG werror("Kerberos.Context() instantiation error: %s\n", describe_backtrace(err)); #endif } } string status() { return (instantiate_msg ? ("<font color='&usr.warncolor;'>" + instantiate_msg + "</font>") : ""); }
24c1d32004-05-14Anders Johansson #else /* !constant(Kerberos.Context) */
d592af2004-05-14Marcus Wellhardh  constant dont_dump_program = 1; string status() {
4acc0a2004-06-09Jonas Wallden  return "<font color='&usr.warncolor;'>Kerberos not available in this Roxen.</font>";
d592af2004-05-14Marcus Wellhardh } #endif /* constant(Kerberos.Context) */
91a9562004-05-14Marcus Wellhardh TAGDOCUMENTATION; #ifdef manual constant tagdoc=([
24c1d32004-05-14Anders Johansson "if#kerberos-auth":#"<desc type='plugin'><p><short>
4acc0a2004-06-09Jonas Wallden  Returns true if the Kerberos authentication is successful.</short>
24c1d32004-05-14Anders Johansson  The username is provided in the plugin attribute.</p>
91a9562004-05-14Marcus Wellhardh  <ex-box> <if kerberos-auth=\"username\" password=\"password\"> <p>The user is authenticated.</p> </if> </ex-box> </desc> <attr name='password' value='string' required='required'><p> Specifies the password.</p> </attr>", ]); #endif