-
Notifications
You must be signed in to change notification settings - Fork 14
/
templateData.go
228 lines (216 loc) · 6.98 KB
/
templateData.go
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package main
import (
"time"
)
const headerTemplateText = `
{{define "header"}}
<div class="header">
<table style="width:100%;border-collapse: separate;border-spacing: 0;">
<tr>
<th style="text-align:left;"> <div class="header_extra">{{template "header_extra"}}</div></th>
<th style="text-align:right;padding-right: .5em;"> {{if .AuthUsername}} <b> {{.AuthUsername}} </b> <a href="/api/v0/logout" >Logout </a> {{end}}</th>
</tr>
</table>
</div>
{{end}}
`
const footerTemplateText = `
{{define "footer"}}
<div class="footer">
<hr>
<center>
Copright 2017 Symantec Corporation. {{template "footer_extra"}}
</center>
</div>
{{end}}
`
type loginPageTemplateData struct {
Title string
AuthUsername string
JSSources []string
ShowOauth2 bool
HideStdLogin bool
}
//Should be a template
const loginFormText = `
{{define "loginPage"}}
<!DOCTYPE html>
<html style="height:100%; padding:0;border:0;margin:0">
<head>
<meta charset="UTF-8">
<title>{{.Title}}</title>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Droid+Sans" />
<link rel="stylesheet" type="text/css" href="/custom_static/customization.css">
<link rel="stylesheet" type="text/css" href="/static/keymaster.css">
</head>
<body>
<div style="min-height:100%;position:relative;">
{{template "header" .}}
<div style="padding-bottom:60px; margin:1em auto; max-width:80em; padding-left:20px ">
<h2> Keymaster Login </h2>
{{if .ShowOauth2}}
<p>
<a href="/auth/oauth2/login"> Oauth2 Login </a>
</p>
{{end}}
{{if not .HideStdLogin}}
<form enctype="application/x-www-form-urlencoded" action="/api/v0/login" method="post">
<p>Username: <INPUT TYPE="text" NAME="username" SIZE=18></p>
<p>Password: <INPUT TYPE="password" NAME="password" SIZE=18></p>
<p><input type="submit" value="Submit" /></p>
</form>
{{end}}
</div>
{{template "footer" . }}
</div>
</body>
</html>
{{end}}
`
type secondFactorAuthTemplateData struct {
Title string
AuthUsername string
JSSources []string
ShowOTP bool
ShowU2F bool
}
const secondFactorAuthFormText = `
{{define "secondFactorLoginPage"}}
<!DOCTYPE html>
<html style="height:100%; padding:0;border:0;margin:0">
<head>
<meta charset="UTF-8">
<title>{{.Title}}</title>
{{if .JSSources -}}
{{- range .JSSources }}
<script type="text/javascript" src="{{.}}"></script>
{{- end}}
{{- end}}
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Droid+Sans" />
<link rel="stylesheet" type="text/css" href="/custom_static/customization.css">
<link rel="stylesheet" type="text/css" href="/static/keymaster.css">
</head>
<body>
<div style="min-height:100%;position:relative;">
{{template "header" .}}
<div style="padding-bottom:60px; margin:1em auto; max-width:80em; padding-left:20px ">
<h2> Keymaster second factor Authenticaion </h2>
{{if .ShowOTP}}
<form enctype="application/x-www-form-urlencoded" action="/api/v0/vipAuth" method="post">
<p>
Enter VIP token value: <INPUT TYPE="text" NAME="OTP" SIZE=18>
<input type="submit" value="Submit" />
</p>
</form>
{{if .ShowU2F}}
<p>
<h4>Or</h4>
</p>
{{end}}
{{end}}
{{if .ShowU2F}}
<p>
<div id="auth_action_text" > Authenticate by touching a blinking registered U2F device (insert if not inserted yet)</div>
</p>
{{end}}
</div>
{{template "footer" . }}
</div>
</body>
</html>
{{end}}
`
type registeredU2FTokenDisplayInfo struct {
RegistrationDate time.Time
DeviceData string
Name string
Index int64
Enabled bool
}
type profilePageTemplateData struct {
Title string
AuthUsername string
Username string
JSSources []string
ShowU2F bool
RegisteredToken []registeredU2FTokenDisplayInfo
}
//{{ .Date | formatAsDate}} {{ printf "%-20s" .Description }} {{.AmountInCents | formatAsDollars -}}
const profileHTML = `
{{define "userProfilePage"}}
<!DOCTYPE html>
<html style="height:100%; padding:0;border:0;margin:0">
<head>
<title>{{.Title}}</title>
{{if .JSSources -}}
{{- range .JSSources }}
<script type="text/javascript" src="{{.}}"></script>
{{- end}}
{{- end}}
<!-- The original u2f-api.js code can be found here:
https://github.com/google/u2f-ref-code/blob/master/u2f-gae-demo/war/js/u2f-api.js -->
<!-- script type="text/javascript" src="https://demo.yubico.com/js/u2f-api.js"></script-->
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Droid+Sans" />
<link rel="stylesheet" type="text/css" href="/custom_static/customization.css">
<link rel="stylesheet" type="text/css" href="/static/keymaster.css">
</head>
<body>
<div style="min-height:100%;position:relative;">
{{template "header" .}}
<div style="padding-bottom:60px; margin:1em auto; max-width:80em; padding-left:20px ">
{{with $top := . }}
<h1>Keymaster User Profile</h1>
<h2> {{.Username}}</h2>
<ul>
<li><a href="/api/v0/logout" >Logout </a></li>
{{if .ShowU2F}}
<li>
<a id="register_button" href="#">Register token</a>
<div id="register_action_text" style="color: blue;background-color: yellow; display: none;"> Please Touch the blinking device to register(insert if not inserted yet) </div>
</li>
<li><a id="auth_button" href="#">Authenticate</a>
<div id="auth_action_text" style="color: blue;background-color: yellow; display: none;"> Please Touch the blinking device to authenticate(insert if not inserted yet) </div>
</li>
{{else}}
<div id="auth_action_text" style="color: blue;background-color: yellow;"> Your browser does not support U2F. However you can still Enable/Disable/Delete U2F tokens </div>
{{end}}
</ul>
{{if .RegisteredToken -}}
Your U2F Token(s):
<table>
<tr>
<th>Name</th>
<th>Device Data</th>
<th>Actions</th>
</tr>
{{- range .RegisteredToken }}
<tr>
<form enctype="application/x-www-form-urlencoded" action="/api/v0/manageU2FToken" method="post">
<input type="hidden" name="index" value="{{.Index}}">
<input type="hidden" name="username" value="{{$top.Username}}">
<td> <input type="text" name="name" value="{{ .Name}}" SIZE=18 > </td>
<td> {{ .DeviceData}} </td>
<td>
<input type="submit" name="action" value="Update" {{if not .Enabled}} disabled {{end}}/>
{{if .Enabled}}
<input type="submit" name="action" value="Disable"/>
{{ else }}
<input type="submit" name="action" value="Enable"/>
<input type="submit" name="action" value="Delete" {{if .Enabled}} disabled {{end}}/>
{{ end }}
</td>
</form>
</tr>
{{- end}}
</table>
{{- else}}
You Dont have any registered tokens.
{{- end}}
{{end}}
</div>
{{template "footer" . }}
</div>
</body>
</html>
{{end}}
`