Certificate requests
[hcoop/zz_old/portal.git] / cert.mlt
1 <% @header [("title", ["SSL certificate permission requests"])];
2
3 val admin = Group.inGroupName "server";
4
5 if $"new" <> "" then
6 if $"kind" = "cert" then
7 if $"req" <> "" then
8 %><h3>You filled data in next to a textbox but didn't check the radio button next to it.</h3><%
9 else
10 val cert = $"cert";
11 val msg = $"msg";
12
13 %>Are you sure you want to ask for permissions on an SSL certificate at <% cert %>?<br><br>
14 <a href="cert?cmd=request&req=Certificate+<% cert %>&msg=<% Web.urlEncode msg %>">Yes, I want to request that.</a><%
15 end
16 else
17 if $"cert" <> "" then
18 %><h3>You filled data in next to a textbox but didn't check the radio button next to it.</h3><%
19 else
20 val req = $"req";
21 val msg = $"msg";
22
23 %>Are you sure you want to ask for permissions on an SSL certificate to be created from an OpenSSL request at <% req %>?<br><br>
24 <a href="cert?cmd=request&req=OpenSSL+request+<% req %>&msg=<% Web.urlEncode msg %>">Yes, I want to request that.</a><%
25 end
26 end
27
28 elseif $"cmd" = "request" then
29 val id = Cert.add (Init.getUserId (), $"req", $"msg");
30 if not (Cert.notifyNew id) then
31 %><h3>Error sending e-mail notification</h3><%
32 end
33 %><h3>Request added</h3><%
34
35 elseif $"cmd" = "open" then
36 %><h3>Open requests</h3>
37 <a href="cert?cmd=list">List all requests</a><%
38
39 foreach (name, req) in Cert.listOpen () do %>
40 <br><hr><br>
41 <table class="blanks">
42 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
43 <tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
44 <tr> <td>Request:</td> <td><% #data req %></td> </tr>
45 <tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
46 </table>
47
48 <% if admin then %>
49 <br>
50 <a href="cert?mod=<% #id req %>">[Modify]</a>
51 <a href="cert?del=<% #id req %>">[Delete]</a><br>
52 To install, run: <i>tell adamc what text to put here</i>.
53 <% end %>
54
55 <% end
56
57 elseif $"cmd" = "list" then
58 %><h3>All requests</h3><%
59
60 foreach (name, req) in Cert.list () do %>
61 <br><hr><br>
62 <table class="blanks">
63 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
64 <tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
65 <tr> <td>Request:</td> <td><% #data req %></td> </tr>
66 <tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
67 </table>
68
69 <% if admin then %>
70 <br>
71 <a href="cert?mod=<% #id req %>">[Modify]</a>
72 <a href="cert?del=<% #id req %>">[Delete]</a>
73 <% end %>
74
75 <% end
76
77 elseif $"mod" <> "" then
78 Group.requireGroupName "server";
79 val id = Web.stoi ($"mod");
80 val req = Cert.lookup id;
81 val user = Init.lookupUser (#usr req) %>
82 <h3>Handle request</h3>
83
84 <form method="post">
85 <input type="hidden" name="save" value="<% id %>">
86 <table class="blanks">
87 <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
88 <tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
89 <tr> <td>Status:</td> <td><select name="status">
90 <option value="0"<% if #status req = Cert.NEW then %> selected<% end %>>New</option>
91 <option value="1"<% if #status req = Cert.INSTALLED then %> selected<% end %>>Installed</option>
92 <option value="2"<% if #status req = Cert.REJECTED then %> selected<% end %>>Rejected</option>
93 </select></td> </tr>
94 <tr> <td>Request:</td> <td><input name="req" size="60" value="<% Web.html (#data req) %>"></td> </tr>
95 <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
96 <tr> <td><input type="submit" value="Save"></td> </tr>
97 </table>
98 </form>
99
100 <% elseif $"save" <> "" then
101 Group.requireGroupName "server";
102 val id = Web.stoi ($"save");
103 val req = Cert.lookup id;
104 val oldStatus = #status req;
105 val newStatus = Cert.statusFromInt (Web.stoi ($"status"));
106 Cert.modify {req with data = $"req", msg = $"msg", status = newStatus};
107 if oldStatus <> newStatus then
108 if not (Cert.notifyMod (oldStatus, newStatus, Init.getUserName(), id)) then
109 %><h3>Error sending e-mail notification</h3><%
110 end
111 end
112 %><h3>Request modified</h3>
113 Back to: <a href="cert?cmd=open">open requests</a>, <a href="cert?cmd=list">all requests</a>
114
115 <% elseif $"del" <> "" then
116 Group.requireGroupName "server";
117 val id = Web.stoi ($"del");
118 val req = Cert.lookup id;
119 val user = Init.lookupUser (#usr req)
120 %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3>
121 <a href="cert?del2=<% id %>">Yes, I'm sure!</a>
122
123 <% elseif $"del2" <> "" then
124 Group.requireGroupName "server";
125 val id = Web.stoi ($"del2");
126 Cert.delete id
127 %><h3>Request deleted</b><h3>
128 Back to: <a href="cert?cmd=open">open requests</a>, <a href="cert?cmd=list">all requests</a>
129
130 <% else %>
131
132 <h3>Request permissions on an SSL certificate</h3>
133
134 <p>Use this form to request use Domtool permissions to use an SSL certificate. Give the location of your certificate request or certificate within <tt>/afs/hcoop.net</tt>. If you have your own certificate signed by an outside provider like Verisign, then choose the second option and give the path to that certificate. If you want your certificate authenticated by chaining through HCoop's root certificate, then choose the first option and give the path to an OpenSSL certificate request.</p>
135
136 <form method="post">
137 <input type="hidden" name="new" value="1">
138 <table class="blanks">
139 <tr> <td>OpenSSL request: <input type="radio" name="kind" value="req" checked></td> <td><input name="req" size="60"></td> </tr>
140 <tr> <td>OpenSSL certificate: <input type="radio" name="kind" value="cert"></td> <td><input name="cert" size="60"></td> </tr>
141 <tr> <td>Additional comments:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
142 <tr> <td><input type="submit" value="Request"></td> </tr>
143 </table>
144 </form>
145
146 <% end %>
147
148 <% @footer[] %>