-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
216 lines (201 loc) · 9.62 KB
/
index.html
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
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.validate.min.js"></script>
<link rel="stylesheet" href="custom.css"/>
<script type="text/javascript" src="auth.js"></script>
<title>Liferay - OAuth2 Tester</title>
<script>
</script>
</head>
<body>
<div class="row">
<div class="col-8">
<h1>Liferay OAuth2 Tester</h1>
<div class="message">You must configure in your Liferay Portal an OAuth2 Application and set<br />
<ul>
<li>callback: <u><i><span id="callbackURI"></span>?url=YOUR_LIFERAY_URL&client_id=YOUR_CLIENT_ID</i></u></li>
<li>scope: <i>everything.read.userprofile</i></li>
</ul>
</div>
</div>
<div class="col-4">
<a href="pkce" class="btn btn-info">Use PKCE Authorization Code Grant Flow</a>
</div>
</div>
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5>Insert the following data:</h5>
</div>
<div class="modal-body">
<form id="modalForm">
<div class="form-row">
<label for="modalLiferayUrl">Liferay URL:</label>
<input type="text" class="form-control" name="modalLiferayUrl" id="modalLiferayUrl" required="required" value="http://localhost:8080" />
</div>
<div class="form-row">
<label for="modalClientId">Client ID:</label>
<input type="text" class="form-control" name="modalClientId" id="modalClientId" required="required" />
</div>
<div class="form-row">
<label for="modalClientSecret">Client Secret:</label>
<input type="password" class="form-control" name="modalClientSecret" id="modalClientSecret" required="required" />
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" onclick="copyModalData();">Continue</button>
</div>
</div>
</div>
</div>
<div class="accordion">
<div class="card">
<div class="card-header" id="auth">
<div class="form-row">
<div class="col-6"><h2 id="step1"><button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">1. Obtain Liferay Authorization</button></h2></div>
<div class="col-6 alignRight"><button id="haveToken" data-toggle="modal" data-target="#modal" class="btn btn-warning">I already have a Token</button></div>
</div>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="auth" data-parent="#accordion">
<form id="authForm">
<div class="form-group">
<label for="liferayUrl">Liferay Portal URL:</label>
<input type="text" class="form-control" id="liferayUrl" name="liferayUrl" required="required" value="http://localhost:8080" />
</div>
<div class="form-row">
<div class="col-6">
<label for="service">OAuth2 Authentication URL:</label>
<input type="text" name="authorizeUrl" id="authorizeUrl" value="/o/oauth2/authorize" class="form-control" />
</div>
<div class="col-6">
<label for="clientId">Client ID:</label>
<input type="text" class="form-control" id="clientId" name="clientId" required="required" />
</div>
</div>
</form>
<button class="btn btn-primary" id="getAuthorizationCode" onclick="getAuthorizationCode();">Authorize My Application</button>
</div>
</div>
<div class="card">
<div class="card-header" id="tokenTab">
<h2 id="step2">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">2. Obtain OAuth2 Token</button>
</h2>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="tokenTab" data-parent="#accordion">
<form id="tokenForm">
<div class="form-row">
<div class="col-6">
<label for="tokenLiferayUrl">Liferay URL:</label>
<input type="text" id="tokenLiferayUrl" name="tokenLiferayUrl" disabled="disabled" class="form-control" />
</div>
<div class="col-6">
<label for="tokenClientId">Client ID:</label>
<input type="text" id="tokenClientId" name="tokenClientId" disabled="disabled" class="form-control" />
</div>
</div>
<div class="form-row">
<div class="col-6">
<label for="code">Auth Code:</label>
<input type="text" disabled="disabled" id="code" name="code" class="form-control" />
</div>
<div class="col-6">
<label for="service">OAuth2 Token URL:</label>
<input type="text" name="tokenUrl" id="tokenUrl" value="/o/oauth2/token" class="form-control" required="required" />
</div>
</div>
<div class="form-group">
<label for="clientSecretId">Client Secret ID:</label>
<input type="password" id="clientSecretId" name="clientSecretId" class="form-control" required="required" />
</div>
</form>
<button id="getToken" class="btn btn-primary" onclick="getToken();">Obtain OAuth2 Access</button>
</div>
</div>
<div class="card">
<div class="card-header" id="apio">
<h2>
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="true" aria-controls="collapseThree">3. Request</button>
</h2>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="apio" data-parent="#accordion">
<form id="requestForm">
<div class="form-row">
<div class="col-6">
<label for="service">URL:</label>
<input type="text" name="url" id="url" class="form-control" required="required" value="http://localhost:8080/api/jsonws/user/get-current-user" />
</div>
<div class="col-2">
<label for="type">Method:</label>
<select onchange="checkMethod(event)" class="form-control" id="methodType" name="methodType">
<option value="DELETE">DELETE</option>
<option selected="selected" value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
</select>
</div>
<div class="col-4">
<label for="type">Content-Type:</label>
<select class="form-control" id="contentType" name="contentType">
<option selected="selected"value="application/json">application/json</option>
<option value="application/x-www-form-urlencoded">x-www-form-urlencoded</option>
</select>
</div>
</div>
<br/>
<div id="parametersList">
<div id="param0" class="row">
<div class="col"><input type="text" id="paramName0" placeholder="Name" class="form-control form-control-sm" /></div>
<div class="col"><input type="text" id="paramValue0" placeholder="Value" class="form-control form-control-sm" /></div>
</div>
</div>
<br/>
<button id="addParameter" class="btn btn-success btn-sm">Add another parameter</button><br/>
<br/>
<div class="row">
<div class="col-6">
<button id="getApioCustom" class="btn btn-primary" onclick="request(event, $('#service').val());">Launch Request</button>
</div>
<div class="col-6">
<label for="token">Access Token: </label>
<input type="text" id="token" name="token" class="form-control form-control-sm" />
</div>
</div>
<div class="row">
<div class="col-6"></div>
<div class="col-6">
<button id="refreshTokenButton" class="btn btn-warning btn-sm" onclick="refreshAccessToken(event);">Refresh Token</button>
<button id="introspectTokenButton" class="btn btn-warning btn-sm" onclick="introspectAccessToken(event);">Introspect Access Token</button>
</div>
</div>
<div class="row">
<div class="col-6"></div>
<div class="col-6">
<label for="refreshToken">Refresh Token: </label>
<input type="text" id="refreshToken" name="refreshToken" class="form-control form-control-sm" />
</div>
</div>
<div class="row">
<div class="col-6"></div>
<div class="col-6">
<button id="introspectRefreshTokenButton" class="btn btn-warning btn-sm" onclick="introspectRefreshToken(event);">Introspect Refresh Token</button>
</div>
</div>
<div class="row">
<div class="col-12"><h5>Request Result: </h5></div>
<div class="col-12" id="result">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>