Skip to content

Commit

Permalink
fix(mail): only apply IMAP host constraint when SSO is enabled
Browse files Browse the repository at this point in the history
Fixes #5433
  • Loading branch information
cgx committed Nov 29, 2021
1 parent e62dd42 commit 8cb5ef3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions SoObjects/Mailer/SOGoMailBaseObject.m
@@ -1,6 +1,5 @@
/*
Copyright (C) 2007-2014 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
Copyright (C) 2007-2021 Inverse inc.
This file is part of SOGo.
Expand Down Expand Up @@ -31,6 +30,7 @@
#import <NGImap4/NGImap4Client.h>

#import <SOGo/SOGoCache.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/WORequest+SOGo.h>

Expand Down Expand Up @@ -134,14 +134,21 @@ - (NGImap4Connection *) _createIMAP4Connection
NGImap4Connection *newConnection;
NSString *password;
NSHost *host;
SOGoSystemDefaults *sd;
BOOL usesSSO;

[self imap4URL];

// We first check if we're trying to establish an IMAP connection to localhost
// for an account number greater than 0 (default account). We prevent that
// for security reasons if admins use an IMAP trust.
host = [NSHost hostWithName: [[self imap4URL] host]];

sd = [SOGoSystemDefaults sharedSystemDefaults];
usesSSO = [[sd authenticationType] isEqualToString: @"cas"] || [[sd authenticationType] isEqualToString: @"saml2"];

if (![[[self mailAccountFolder] nameInContainer] isEqualToString: @"0"] &&
usesSSO &&
[[host address] isEqualToString: @"127.0.0.1"])
{
[self errorWithFormat: @"Trying to use localhost for additional IMAP account - aborting."];
Expand Down
Expand Up @@ -9,13 +9,13 @@
*/
AccountDialogController.$inject = ['$timeout', '$window', '$mdConstant', '$mdDialog', 'FileUploader', 'Dialog', 'sgSettings', 'defaults', 'account', 'accountId', 'mailCustomFromEnabled'];
function AccountDialogController($timeout, $window, $mdConstant, $mdDialog, FileUploader, Dialog, Settings, defaults, account, accountId, mailCustomFromEnabled) {
var vm = this;
var vm = this, usesSSO = $window.usesCASAuthentication || $window.usesSAML2Authentication;

this.defaultPort = 143;
this.defaults = defaults;
this.account = account;
this.accountId = accountId;
this.hostnameRE = accountId > 0 ? /^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/ : /./;
this.hostnameRE = usesSSO && accountId > 0 ? /^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/ : /./;
this.addressesSearchText = '';
this.emailSeparatorKeys = [
$mdConstant.KEY_CODE.ENTER,
Expand Down

0 comments on commit 8cb5ef3

Please sign in to comment.