1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
// This is a ChiliMoon module. Copyright © 2004, Roxen IS. 
// 
 
#include <module.h> 
inherit "module"; 
 
constant cvs_version = "$Id: kerberos.pike,v 1.1 2004/07/12 00:13:52 _cvs_stephen Exp $"; 
constant thread_safe = 1; 
constant module_type = MODULE_TAG; 
constant module_name = "Tags: Support for Kerberos authentication"; 
constant module_doc  = ("Adds a couple of tags to enable simple Kerberos " 
                        "authentication."); 
constant module_unique = 1; 
 
#if constant(Kerberos.Context) 
Kerberos.Context ctx; 
string instantiate_msg; 
 
class TagIfKerberosAuth { 
  inherit RXML.Tag; 
  constant name = "if"; 
  constant plugin_name = "kerberos-auth"; 
 
  int eval(string user, RequestID id, mapping args) 
  { 
    if (!ctx) 
      RXML.run_error("The Kerberos module is not active.\n"); 
     
    if(!args->password) 
      RXML.parse_error("No password attribute specified.\n"); 
     
    NOCACHE(); 
 
    return ctx->authenticate(user, args->password); 
  } 
} 
 
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>") : 
          ""); 
} 
 
 
#else /* !constant(Kerberos.Context) */ 
 
constant dont_dump_program = 1; 
 
string status() 
{ 
  return "<font color='&usr.warncolor;'>Kerberos not available in this Roxen.</font>"; 
} 
 
#endif /* constant(Kerberos.Context) */ 
 
TAGDOCUMENTATION; 
#ifdef manual 
constant tagdoc=([ 
"if#kerberos-auth":#"<desc type='plugin'><p><short> 
 Returns true if the Kerberos authentication is successful.</short> 
 The username is provided in the plugin attribute.</p> 
 
<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