diff options
author | James Moger <james.moger@gitblit.com> | 2013-06-17 15:56:14 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-06-17 15:56:14 -0400 |
commit | 9b54923f4ee5411966016f91224e4f4f545f1416 (patch) | |
tree | ab5d381f6aa1501fe351502fb2d88736414e354e /src/main/java/com/gitblit/GitBlit.java | |
parent | de3474a1ddd9201dec8246d7fd81e240b98bb6a5 (diff) | |
download | gitblit-9b54923f4ee5411966016f91224e4f4f545f1416.tar.gz gitblit-9b54923f4ee5411966016f91224e4f4f545f1416.zip |
Option to auto-create accounts based on authenticated container principals (issue-246)
Diffstat (limited to 'src/main/java/com/gitblit/GitBlit.java')
-rw-r--r-- | src/main/java/com/gitblit/GitBlit.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index c538acea..25ffaba8 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -827,13 +827,24 @@ public class GitBlit implements ServletContextListener { Principal principal = httpRequest.getUserPrincipal(); if (principal != null) { String username = principal.getName(); - if (StringUtils.isEmpty(username)) { + if (!StringUtils.isEmpty(username)) { UserModel user = getUserModel(username); if (user != null) { + // existing user flagWicketSession(AuthenticationType.CONTAINER); logger.debug(MessageFormat.format("{0} authenticated by servlet container principal from {1}", user.username, httpRequest.getRemoteAddr())); return user; + } else if (settings.getBoolean(Keys.realm.container.autoCreateAccounts, true)) { + // auto-create user from an authenticated container principal + user = new UserModel(username.toLowerCase()); + user.displayName = username; + user.password = Constants.EXTERNAL_ACCOUNT; + userService.updateUserModel(user); + flagWicketSession(AuthenticationType.CONTAINER); + logger.debug(MessageFormat.format("{0} authenticated and created by servlet container principal from {1}", + user.username, httpRequest.getRemoteAddr())); + return user; } else { logger.warn(MessageFormat.format("Failed to find UserModel for {0}, attempted servlet container authentication from {1}", principal.getName(), httpRequest.getRemoteAddr())); |