forked from jenkinsci/github-oauth-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGithubSecurityRealm.java
685 lines (594 loc) · 24.8 KB
/
GithubSecurityRealm.java
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
/**
The MIT License
Copyright (c) 2011-2016 Michael O'Cleirigh, James Nord, CloudBees, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package org.jenkinsci.plugins;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import hudson.Extension;
import hudson.ProxyConfiguration;
import hudson.Util;
import hudson.model.Descriptor;
import hudson.model.User;
import hudson.security.GroupDetails;
import hudson.security.SecurityRealm;
import hudson.security.UserMayOrMayNotExistException;
import hudson.tasks.Mailer;
import hudson.util.Secret;
import jenkins.model.Jenkins;
import jenkins.security.SecurityListener;
import org.acegisecurity.Authentication;
import org.acegisecurity.AuthenticationException;
import org.acegisecurity.AuthenticationManager;
import org.acegisecurity.BadCredentialsException;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jfree.util.Log;
import org.kohsuke.github.GHEmail;
import org.kohsuke.github.GHMyself;
import org.kohsuke.github.GHOrganization;
import org.kohsuke.github.GHTeam;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.Header;
import org.kohsuke.stapler.HttpRedirect;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.StaplerRequest;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataRetrievalFailureException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;
/**
*
* Implementation of the AbstractPasswordBasedSecurityRealm that uses github
* oauth to verify the user can login.
*
* This is based on the MySQLSecurityRealm from the mysql-auth-plugin written by
* Alex Ackerman.
*/
public class GithubSecurityRealm extends SecurityRealm implements UserDetailsService {
private static final String DEFAULT_WEB_URI = "https://github.com";
private static final String DEFAULT_API_URI = "https://api.github.com";
private static final String DEFAULT_ENTERPRISE_API_SUFFIX = "/api/v3";
private static final String DEFAULT_OAUTH_SCOPES = "read:org,user:email";
private String githubWebUri;
private String githubApiUri;
private String clientID;
private Secret clientSecret;
private String oauthScopes;
private String[] myScopes;
/**
* @param githubWebUri The URI to the root of the web UI for GitHub or GitHub Enterprise,
* including the protocol (e.g. https).
* @param githubApiUri The URI to the root of the API for GitHub or GitHub Enterprise,
* including the protocol (e.g. https).
* @param clientID The client ID for the created OAuth Application.
* @param clientSecret The client secret for the created GitHub OAuth Application.
* @param oauthScopes A comma separated list of OAuth Scopes to request access to.
*/
@DataBoundConstructor
public GithubSecurityRealm(String githubWebUri,
String githubApiUri,
String clientID,
String clientSecret,
String oauthScopes) {
super();
this.githubWebUri = Util.fixEmptyAndTrim(githubWebUri);
this.githubApiUri = Util.fixEmptyAndTrim(githubApiUri);
this.clientID = Util.fixEmptyAndTrim(clientID);
setClientSecret(Util.fixEmptyAndTrim(clientSecret));
this.oauthScopes = Util.fixEmptyAndTrim(oauthScopes);
}
private GithubSecurityRealm() { }
/**
* Tries to automatically determine the GitHub API URI based on
* a GitHub Web URI.
*
* @param githubWebUri The URI to the root of the Web UI for GitHub or GitHub Enterprise.
* @return The expected API URI for the given Web UI
*/
private String determineApiUri(String githubWebUri) {
if(githubWebUri.equals(DEFAULT_WEB_URI)) {
return DEFAULT_API_URI;
} else {
return githubWebUri + DEFAULT_ENTERPRISE_API_SUFFIX;
}
}
/**
* @param githubWebUri
* the string representation of the URI to the root of the Web UI for
* GitHub or GitHub Enterprise.
*/
private void setGithubWebUri(String githubWebUri) {
this.githubWebUri = githubWebUri;
}
/**
* @param clientID the clientID to set
*/
private void setClientID(String clientID) {
this.clientID = clientID;
}
/**
* @param clientSecret the clientSecret to set
*/
private void setClientSecret(String clientSecret) {
this.clientSecret = Secret.fromString(clientSecret);
}
/**
* @param oauthScopes the oauthScopes to set
*/
private void setOauthScopes(String oauthScopes) {
this.oauthScopes = oauthScopes;
}
/**
* Checks the security realm for a GitHub OAuth scope.
* @param scope A scope to check for in the security realm.
* @return true if security realm has the scope or false if it does not.
*/
public boolean hasScope(String scope) {
if(this.myScopes == null) {
this.myScopes = this.oauthScopes.split(",");
Arrays.sort(this.myScopes);
}
return Arrays.binarySearch(this.myScopes, scope) >= 0;
}
/**
*
* @return the URI to the API root of GitHub or GitHub Enterprise.
*/
public String getGithubApiUri() {
return githubApiUri;
}
/**
* @param githubApiUri the URI to the API root of GitHub or GitHub Enterprise.
*/
private void setGithubApiUri(String githubApiUri) {
this.githubApiUri = githubApiUri;
}
public static final class ConverterImpl implements Converter {
public boolean canConvert(Class type) {
return type == GithubSecurityRealm.class;
}
public void marshal(Object source, HierarchicalStreamWriter writer,
MarshallingContext context) {
GithubSecurityRealm realm = (GithubSecurityRealm) source;
writer.startNode("githubWebUri");
writer.setValue(realm.getGithubWebUri());
writer.endNode();
writer.startNode("githubApiUri");
writer.setValue(realm.getGithubApiUri());
writer.endNode();
writer.startNode("clientID");
writer.setValue(realm.getClientID());
writer.endNode();
writer.startNode("clientSecret");
writer.setValue(realm.getClientSecret().getEncryptedValue());
writer.endNode();
writer.startNode("oauthScopes");
writer.setValue(realm.getOauthScopes());
writer.endNode();
}
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
GithubSecurityRealm realm = new GithubSecurityRealm();
String node;
String value;
while (reader.hasMoreChildren()) {
reader.moveDown();
node = reader.getNodeName();
value = reader.getValue();
setValue(realm, node, value);
reader.moveUp();
}
if (realm.getGithubWebUri() == null) {
realm.setGithubWebUri(DEFAULT_WEB_URI);
}
if (realm.getGithubApiUri() == null) {
realm.setGithubApiUri(DEFAULT_API_URI);
}
return realm;
}
private void setValue(GithubSecurityRealm realm, String node,
String value) {
if (node.toLowerCase().equals("clientid")) {
realm.setClientID(value);
} else if (node.toLowerCase().equals("clientsecret")) {
realm.setClientSecret(value);
} else if (node.toLowerCase().equals("githubweburi")) {
realm.setGithubWebUri(value);
} else if (node.toLowerCase().equals("githuburi")) { // backwards compatibility for old field
realm.setGithubWebUri(value);
String apiUrl = realm.determineApiUri(value);
realm.setGithubApiUri(apiUrl);
} else if (node.toLowerCase().equals("githubapiuri")) {
realm.setGithubApiUri(value);
} else if (node.toLowerCase().equals("oauthscopes")) {
realm.setOauthScopes(value);
} else {
throw new ConversionException("Invalid node value = " + node);
}
}
}
/**
* @return the uri to the web root of Github (varies for Github Enterprise Edition)
*/
public String getGithubWebUri() {
return githubWebUri;
}
/**
* @deprecated use {@link org.jenkinsci.plugins.GithubSecurityRealm#getGithubWebUri()} instead.
* @return the uri to the web root of Github (varies for Github Enterprise Edition)
*/
@Deprecated
public String getGithubUri() {
return getGithubWebUri();
}
/**
* @return the clientID
*/
public String getClientID() {
return clientID;
}
/**
* @return the clientSecret
*/
public Secret getClientSecret() {
return clientSecret;
}
/**
* @return the oauthScopes
*/
public String getOauthScopes() {
return oauthScopes;
}
public HttpResponse doCommenceLogin(StaplerRequest request, @Header("Referer") final String referer)
throws IOException {
request.getSession().setAttribute(REFERER_ATTRIBUTE,referer);
Set<String> scopes = new HashSet<>();
for (GitHubOAuthScope s : getJenkins().getExtensionList(GitHubOAuthScope.class)) {
scopes.addAll(s.getScopesToRequest());
}
String suffix="";
if (!scopes.isEmpty()) {
suffix = "&scope="+Util.join(scopes,",");
} else {
// We need repo scope in order to access private repos
// See https://developer.github.com/v3/oauth/#scopes
suffix = "&scope=" + oauthScopes;
}
return new HttpRedirect(githubWebUri + "/login/oauth/authorize?client_id="
+ clientID + suffix);
}
/**
* This is where the user comes back to at the end of the OAuth redirect
* ping-pong.
*/
public HttpResponse doFinishLogin(StaplerRequest request)
throws IOException {
String code = request.getParameter("code");
if (code == null || code.trim().length() == 0) {
Log.info("doFinishLogin: missing code.");
return HttpResponses.redirectToContextRoot();
}
String accessToken = getAccessToken(code);
if (accessToken != null && accessToken.trim().length() > 0) {
// only set the access token if it exists.
GithubAuthenticationToken auth = new GithubAuthenticationToken(accessToken, getGithubApiUri());
SecurityContextHolder.getContext().setAuthentication(auth);
GHMyself self = auth.getMyself();
User u = User.current();
if (u == null) {
throw new IllegalStateException("Can't find user");
}
u.setFullName(self.getName());
// Set email from github only if empty
if (!u.getProperty(Mailer.UserProperty.class).hasExplicitlyConfiguredAddress()) {
if(hasScope("user") || hasScope("user:email")) {
String primary_email = null;
for(GHEmail e : self.getEmails2()) {
if(e.isPrimary()) {
primary_email = e.getEmail();
}
}
if(primary_email != null) {
u.addProperty(new Mailer.UserProperty(primary_email));
}
} else {
u.addProperty(new Mailer.UserProperty(auth.getGitHub().getMyself().getEmail()));
}
}
SecurityListener.fireAuthenticated(new GithubOAuthUserDetails(self.getLogin(), auth.getAuthorities()));
} else {
Log.info("Github did not return an access token.");
}
String referer = (String)request.getSession().getAttribute(REFERER_ATTRIBUTE);
if (referer!=null) return HttpResponses.redirectTo(referer);
return HttpResponses.redirectToContextRoot(); // referer should be always there, but be defensive
}
@Nullable
private String getAccessToken(@Nonnull String code) throws IOException {
String content;
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpost = new HttpPost(githubWebUri
+ "/login/oauth/access_token?" + "client_id=" + clientID + "&"
+ "client_secret=" + clientSecret + "&" + "code=" + code);
HttpHost proxy = getProxy(httpost);
if (proxy != null) {
RequestConfig requestConfig = RequestConfig.custom().setProxy(proxy).build();
httpost.setConfig(requestConfig);
}
org.apache.http.HttpResponse response = httpClient.execute(httpost);
HttpEntity entity = response.getEntity();
content = EntityUtils.toString(entity);
}
String parts[] = content.split("&");
for (String part : parts) {
if (content.contains("access_token")) {
String tokenParts[] = part.split("=");
return tokenParts[1];
}
}
return null;
}
/**
* Returns the proxy to be used when connecting to the given URI.
*/
private HttpHost getProxy(HttpUriRequest method) throws URIException {
ProxyConfiguration proxy = getJenkins().proxy;
if (proxy==null) return null; // defensive check
Proxy p = proxy.createProxy(method.getURI().getHost());
switch (p.type()) {
case DIRECT:
return null; // no proxy
case HTTP:
InetSocketAddress sa = (InetSocketAddress) p.address();
return new HttpHost(sa.getHostName(),sa.getPort());
case SOCKS:
default:
return null; // not supported yet
}
}
/*
* (non-Javadoc)
*
* @see hudson.security.SecurityRealm#allowsSignup()
*/
@Override
public boolean allowsSignup() {
return false;
}
@Override
public SecurityComponents createSecurityComponents() {
return new SecurityComponents(new AuthenticationManager() {
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
if (authentication instanceof GithubAuthenticationToken)
return authentication;
if (authentication instanceof UsernamePasswordAuthenticationToken)
try {
UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication;
GithubAuthenticationToken github = new GithubAuthenticationToken(token.getCredentials().toString(), getGithubApiUri());
SecurityContextHolder.getContext().setAuthentication(github);
return github;
} catch (IOException e) {
throw new RuntimeException(e);
}
throw new BadCredentialsException(
"Unexpected authentication type: " + authentication);
}
}, new UserDetailsService() {
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
return GithubSecurityRealm.this.loadUserByUsername(username);
}
});
}
@Override
public String getLoginUrl() {
return "securityRealm/commenceLogin";
}
@Override
protected String getPostLogOutUrl(StaplerRequest req, Authentication auth) {
// if we just redirect to the root and anonymous does not have Overall read then we will start a login all over again.
// we are actually anonymous here as the security context has been cleared
Jenkins j = Jenkins.getInstance();
assert j != null;
if (j.hasPermission(Jenkins.READ)) {
return super.getPostLogOutUrl(req, auth);
}
return req.getContextPath()+ "/" + GithubLogoutAction.POST_LOGOUT_URL;
}
@Extension
public static final class DescriptorImpl extends Descriptor<SecurityRealm> {
@Override
public String getHelpFile() {
return "/plugin/github-oauth/help/help-security-realm.html";
}
@Override
public String getDisplayName() {
return "Github Authentication Plugin";
}
public String getDefaultGithubWebUri() {
return DEFAULT_WEB_URI;
}
public String getDefaultGithubApiUri() {
return DEFAULT_API_URI;
}
public String getDefaultOauthScopes() {
return DEFAULT_OAUTH_SCOPES;
}
public DescriptorImpl() {
super();
// TODO Auto-generated constructor stub
}
public DescriptorImpl(Class<? extends SecurityRealm> clazz) {
super(clazz);
// TODO Auto-generated constructor stub
}
}
// Overridden for better type safety.
// If your plugin doesn't really define any property on Descriptor,
// you don't have to do this.
@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
}
/**
*
* @param username username to lookup
* @return userDetails
* @throws UserMayOrMayNotExistException
* @throws UsernameNotFoundException
* @throws DataAccessException
*/
@Override
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
Authentication token = SecurityContextHolder.getContext().getAuthentication();
if (token == null) {
throw new UserMayOrMayNotExistException("Could not get auth token.");
}
GithubAuthenticationToken authToken;
if (token instanceof GithubAuthenticationToken) {
authToken = (GithubAuthenticationToken) token;
} else {
throw new UserMayOrMayNotExistException("Unexpected authentication type: " + token);
}
/**
* Always lookup the local user first. If we can't resolve it then we can burn an API request to Github for this user
* Taken from hudson.security.HudsonPrivateSecurityRealm#loadUserByUsername(java.lang.String)
*/
User localUser = User.getById(username, false);
if (localUser != null) {
return new GithubOAuthUserDetails(username, authToken);
}
try {
GithubOAuthUserDetails userDetails = authToken.getUserDetails(username);
if (userDetails == null)
throw new UsernameNotFoundException("Unknown user: " + username);
// Check the username is not an homonym of an organization
GHOrganization ghOrg = authToken.loadOrganization(username);
if (ghOrg != null) {
throw new UsernameNotFoundException("user(" + username + ") is also an organization");
}
return userDetails;
} catch (IOException | Error e) {
throw new DataRetrievalFailureException("loadUserByUsername (username=" + username +")", e);
}
}
/**
* Compare an object against this instance for equivalence.
* @param object An object to campare this instance to.
* @return true if the objects are the same instance and configuration.
*/
@Override
public boolean equals(Object object){
if(object instanceof GithubSecurityRealm) {
GithubSecurityRealm obj = (GithubSecurityRealm) object;
return this.getGithubWebUri().equals(obj.getGithubWebUri()) &&
this.getGithubApiUri().equals(obj.getGithubApiUri()) &&
this.getClientID().equals(obj.getClientID()) &&
this.getClientSecret().equals(obj.getClientSecret()) &&
this.getOauthScopes().equals(obj.getOauthScopes());
} else {
return false;
}
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(this.getGithubWebUri())
.append(this.getGithubApiUri())
.append(this.getClientID())
.append(this.getClientSecret())
.append(this.getOauthScopes())
.toHashCode();
}
/**
*
* @param groupName groupName to look up
* @return groupDetails
* @throws UsernameNotFoundException
* @throws DataAccessException
*/
@Override
public GroupDetails loadGroupByGroupname(String groupName)
throws UsernameNotFoundException, DataAccessException {
GithubAuthenticationToken authToken = (GithubAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
if(authToken == null)
throw new UsernameNotFoundException("No known group: " + groupName);
try {
int idx = groupName.indexOf(GithubOAuthGroupDetails.ORG_TEAM_SEPARATOR);
if (idx > -1 && groupName.length() > idx + 1) { // groupName = "GHOrganization*GHTeam"
String orgName = groupName.substring(0, idx);
String teamName = groupName.substring(idx + 1);
LOGGER.config(String.format("Lookup for team %s in organization %s", teamName, orgName));
GHTeam ghTeam = authToken.loadTeam(orgName, teamName);
if (ghTeam == null) {
throw new UsernameNotFoundException("Unknown GitHub team: " + teamName + " in organization "
+ orgName);
}
return new GithubOAuthGroupDetails(ghTeam);
} else { // groupName = "GHOrganization"
GHOrganization ghOrg = authToken.loadOrganization(groupName);
if (ghOrg == null) {
throw new UsernameNotFoundException("Unknown GitHub organization: " + groupName);
}
return new GithubOAuthGroupDetails(ghOrg);
}
} catch (Error e) {
throw new DataRetrievalFailureException("loadGroupByGroupname (groupname=" + groupName + ")", e);
}
}
static Jenkins getJenkins() {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
throw new IllegalStateException("Jenkins not started");
}
return jenkins;
}
/**
* Logger for debugging purposes.
*/
private static final Logger LOGGER = Logger.getLogger(GithubSecurityRealm.class.getName());
private static final String REFERER_ATTRIBUTE = GithubSecurityRealm.class.getName()+".referer";
}