edit.jsp 8.69 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1
2
<!DOCTYPE html>

3
<%@ include file="/WEB-INF/jsp/init.jsp" %>
Matija Obreza's avatar
Matija Obreza committed
4
5

<html>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	<head>
		<title><spring:message code="oauth-client.page.profile.title" arguments="${clientDetails.clientId}"/></title>
	</head>
	<body>
		<form role="form" class="form-horizontal validate" action="<c:url value='/admin/oauth-clients/save-client' />" method="post">
			<c:if test="${clientDetails.id gt 0}">
				<input type="hidden" name="id" value="${clientDetails.id}"/>
			</c:if>
			<input type="hidden" name="version" value="${clientDetails.version}"/>
			<input type="hidden" name="clientId" value="${clientDetails.clientId}"/>
			<c:if test="${clientDetails == null}">
				<input type="hidden" name="newClient" value="new"/>
			</c:if>
			<div class="form-group">
				<label for="clientId" class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.id"/></label>
				<div class="col-lg-9 col-md-8">
					<span class="form-control"><c:out value="${clientDetails.clientId}"/></span>
				</div>
Matija Obreza's avatar
Matija Obreza committed
24
			</div>
25
26
27
28
29
			<div class="form-group">
				<label for="secret" class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.secret"/></label>
				<div class="col-lg-9 col-md-8">
					<input type="text" name="clientSecret" class="form-control" value="<c:out value='${clientDetails.clientSecret}' />"/>
				</div>
Matija Obreza's avatar
Matija Obreza committed
30
			</div>
31
32
33
34
35
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.title"/></label>
				<div class="col-lg-9 col-md-8">
					<input type="text" name="title" class="form-control" value="<c:out value='${clientDetails.title}' />"/>
				</div>
Matija Obreza's avatar
Matija Obreza committed
36
			</div>
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
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.description"/></label>
				<div class="col-lg-9 col-md-8">
					<textarea name="description" class="form-control"><c:out value="${clientDetails.description}"/></textarea>
				</div>
			</div>

			<div class="form-group">
				<label for="redirectUri" class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.redirect.uri"/></label>
				<div class="col-lg-9 col-md-8">
					<textarea style="min-height: 150px" id="redirectUri" name="redirect" class="form-control"><c:forEach items="${clientDetails.registeredRedirectUri}" var="uri"><c:out value="${uri}" />
</c:forEach></textarea>
					<p class="help-block">One per line. For OOB: <code>oob</code>, <code>urn:ietf:wg:oauth:2.0:oob</code></p>
					<ul>
						<c:forEach items="${clientDetails.registeredRedirectUri}" var="uri">
							<li><c:out value="${uri}"/></li>
						</c:forEach>
					</ul>
				</div>
			</div>

			<div class="form-group">
				<label for="redirectUri" class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.access-token.accessTokenValiditySeconds"/></label>
				<div class="col-lg-9 col-md-8">
					<input type="text" name="accessTokenValidity" class="form-control" placeholder="<spring:message code='oauth-client.access-token.defaultDuration' />" value="<c:out value='${clientDetails.accessTokenValidity}' />"/>
				</div>
			</div>
			<div class="form-group">
				<label for="redirectUri" class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.access-token.refreshTokenValiditySeconds"/></label>
				<div class="col-lg-9 col-md-8">
					<input type="text" name="refreshTokenValidity" class="form-control" placeholder="<spring:message code='oauth-client.access-token.defaultDuration'/>" value="<c:out value='${clientDetails.refreshTokenValidity}'/>"/>
				</div>
			</div>

			<!-- Extras -->
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.authorities"/></label>
				<div class="col-lg-9 col-md-8">
					<div class="checkbox">
						<label><input type="checkbox" name="roles[]" ${clientDetails.authorities.contains(ROLE_CLIENT) ? 'checked' : '' } value="CLIENT"/>
							CLIENT</label>
					</div>
					<div class="checkbox">
						<label>
							<input type="checkbox" name="roles[]" ${clientDetails.authorities.contains(ROLE_TRUSTED_CLIENT) ? 'checked' : '' } value="TRUSTED_CLIENT"/>
							TRUSTED_CLIENT</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.resourceIds"/></label>
				<div class="col-lg-9 col-md-8">
					<div class="form-control-static">
						<c:out value="${clientDetails.resourceIds}"/>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.scope"/></label>
				<div class="col-lg-9 col-md-8">
					<div class="checkbox">
						<label><input type="checkbox" name="scopes[]" ${clientDetails.scope.contains('read') ? 'checked' : '' } value="read"/>
							Read</label>
					</div>
					<div class="checkbox">
						<label><input type="checkbox" name="scopes[]" ${clientDetails.scope.contains('write') ? 'checked' : '' } value="write"/>
							Write</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.authorizedGrantTypes"/></label>
				<div class="col-lg-9 col-md-8">
					<div class="checkbox">
						<label><input type="checkbox" name="grantTypes[]" ${clientDetails.authorizedGrantTypes.contains('authorization_code') ? 'checked' : '' } value="authorization_code"/>
							Authorization code</label>
					</div>
					<div class="checkbox">
						<label><input type="checkbox" name="grantTypes[]" ${clientDetails.authorizedGrantTypes.contains('password') ? 'checked' : '' } value="password"/>
							Password</label>
					</div>
					<div class="checkbox">
						<label><input type="checkbox" name="grantTypes[]" ${clientDetails.authorizedGrantTypes.contains('refresh_token') ? 'checked' : '' } value="refresh_token"/>
							Refresh token</label>
					</div>
					<div class="checkbox">
						<label><input type="checkbox" name="grantTypes[]" ${clientDetails.authorizedGrantTypes.contains('client_credentials') ? 'checked' : '' } value="client_credentials"/>
							Client credentials</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.autoApprove"/></label>
				<div class="col-lg-9 col-md-8">
					<div class="radio">
						<label>
							<input type="radio" name="autoApprove" ${clientDetails.autoApprove ? '' : 'checked' } value="false">Do not auto approve</label>
						</div>
						<div class="radio">
							<label>
								<input type="radio" name="autoApprove" ${clientDetails.autoApprove ? 'checked' : '' } value="true">Auto approve</label>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.autoApproveScopes"/></label>
						<div class="col-lg-9 col-md-8">
							<div class="checkbox">
								<label><input type="checkbox" name="autoApproveScopes[]" ${clientDetails.autoApproveScopes.contains('read') ? 'checked' : '' } value="read"/>
									Read</label>
							</div>
							<div class="checkbox">
								<label><input type="checkbox" name="autoApproveScopes[]" ${clientDetails.autoApproveScopes.contains('write') ? 'checked' : '' } value="write"/>
									Write</label>
							</div>
						</div>
					</div>

					<div class="form-group">
						<div class="col-lg-offset-3 col-lg-9">
							<input type="button" onClick="return submitJson(this.form);" value="<spring:message code='save' />" class="btn btn-primary"/>
							<input type="button" name="action-delete" value="<spring:message code='delete' />" class="btn btn-default"/>
							<a class="btn btn-default" href="<c:url value='/admin/oauth-clients/' />" class="btn">
								<spring:message code="cancel"/>
							</a>
						</div>
					</div>
					<!-- CSRF protection -->
					<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
				</form>

				<content tag="javascript">
					<script type="text/javascript">
						function submitJson(form) {
							// console.log('Submitting as JSON', form);
							var data = $(form).serializeObject();
							delete data['_csrf'];
							data.redirectUris = data.redirect.split('\n').map(function(x) { return x.trim(); });
							delete data.redirect;
							console.log(data);
							$.ajax({
								url: form.action + "?action-save=1&id=" + data.id + "&version=" + data.version,
								type: 'POST',
								dataType: 'json',
								contentType: 'application/json; charset=utf-8',
								data: (data === null
									? null
									: JSON.stringify(data)),
								success: function (response) {
									// console.log('saved', response);
									window.location = window.location;
								}
							});
							return false;
						}
					</script>
				</content>
			</body>
		</html>