Project

General

Profile

User auth against an IMAP server - is it wanted?

Added by Tim Jones almost 15 years ago

After some fiddling I have managed to integrate Redmine into my company server setup. In this setting all basic user auth is done against an IMAP server and I have now gotten this working well with Redmine.

I was just wondering, is this a feature that would be wanted by other people? If so, I will try and turn it into a patch/plugin to complement the LDAP auth that already exists.


Replies (6)

RE: User auth against an IMAP server - is it wanted? - Added by Bernhard Furtmueller almost 15 years ago

I don't need it, but if you touch things around here I'd be glad if could also
add simpler support for active directory authentication.

If found out that changing the line below allows me to authenticate against
our ADS without a predefined "readonly" account.
However one must have the DOMAIN configures as shown below. Of course this
should be a setting for this ldap service - but I don't know enough to
do that myself.

app/models/auth_source_ldap.rb

  1. get user's DN
    #ldap_con = initialize_ldap_con(self.account, self.account_password)
    ldap_con = initialize_ldap_con("DOMAIN\\" + login, password) or return nil

RE: User auth against an IMAP server - is it wanted? - Added by Eric Davis almost 15 years ago

I don't need it but it might be useful to someone if you build it into a plugin.

Eric Davis

RE: User auth against an IMAP server - is it wanted? - Added by h.e. l. over 12 years ago

I would appreciate to have such a function natively in redmine or as plugin. This would be a very nice way to use e.G. Microsoft Office 365 accounts for redmine login as Microsoft Office 365 currently does not offer an external LDAP service.

RE: User auth against an IMAP server - is it wanted? - Added by Sunding Wei almost 12 years ago

It was a pity that Tim Jones did not contribute his IMAP authentiocation module.

For those want to centralize the user authentication with IMAP for Redmine, please use the module I contribute.
Attachment also available for download.

  1. Put the module to redmine/app/models/auth_source_imap.rb
  2. Check the comments to setup
  3. NO UI view for this module, hope someone to make it
##
# Redmine IMAP Authentication Module
#
# All rights avoided, you are free to distribute or modify
# the source code under the terms you reserve the author information.
#
# Author:
#     Dingding Technology, Inc.
#     Sunding Wei <swei(at)dingding.me>
#
# File: redmine/app/models/auth_source_imap.rb
#
require "net/imap" 
require 'timeout'

#
# HOWTO
#
# 1. Execute the SQL
#    INSERT INTO auth_sources (type, name) values ("AuthSourceIMAP", "IMAP")
# 2. Change as you like
# 3. Redmine: set the user authentication mode to IMAP
# 4. Restart your web server
#

class AuthSourceIMAP < AuthSource
    def authenticate(login, password)
        # Define your IMAP server
        self.host = "imap.qq.com" 
        self.port = 143
        retVal = {
            :firstname => self.attr_firstname,
            :lastname => self.attr_lastname,
            :mail => self.attr_mail,
            :auth_source_id => self.id
        }
        # Email as account if you use Google Apps
        suffix = "@dingding.me";
        if not login.end_with?(suffix)
            login += suffix
        end
        # Authenticate
        begin
            imap = Net::IMAP.new(self.host, self.port)
            imap.authenticate('LOGIN', login, password)
        rescue Net::IMAP::NoResponseError => e
            retVal = nil
        end
        return retVal
    end

    def auth_method_name
        "IMAP" 
    end
end

RE: User auth against an IMAP server - is it wanted? - Added by Sunding Wei almost 12 years ago

Apache with IMAP authentication

Original from mod_auth_imap, I added Auth_IMAP_Domain option which can be used to login Google Apps. Once Auth_IMAP_Domain was set, login username will be an email address.

Check out the attachment, you need to run build.sh on Ubuntu.

Office365.com authentication. - Added by Thanos Politis about 11 years ago

After a few minor changes to Sunding Wei's code we managed to authenticate with the office365.com service.

##
#RedMine IMAP Authentication Module
#
# All rights avoided, you are free to distribute or modify
# the source code under the terms you reserve the author information.
#
# Author:
#     Dingding Technology, Inc.
#     Sunding Wei <swei(at)dingding.me>
#
# File: redmine/app/models/auth_source_imap.rb
#
require "net/imap" 
require 'timeout'

#
# HOWTO
#
# 1. Execute the SQL
#    INSERT INTO auth_sources (type, name) values ("AuthSourceIMAP", "IMAP")
# 2. Change as you like
# 3. Redmine: set the user authentication mode to IMAP
# 4. Restart your web server
#

class AuthSourceIMAP < AuthSource
    def authenticate(login, password)
        # Define your IMAP server
        self.host = "mail.office365.com" 
        self.port = 993
        retVal = {
            :firstname => self.attr_firstname,
            :lastname => self.attr_lastname,
            :mail => self.attr_mail,
            :auth_source_id => self.id
        }
        # Email as account if you use Google Apps
        suffix = "@yourdomainhere.com";
        if not login.end_with?(suffix)
            login += suffix
        end
        # Authenticate
        options = {
                :port => self.port,
                :ssl => {
                  #add this to bypass OpenSSL::SSL::SSLError 
                  #(hostname does not match the server certificate) error.
                  :verify_mode => OpenSSL::SSL::VERIFY_NONE
                }
        }
        begin
            imap = Net::IMAP.new(self.host, options)
            #substituted imap.authenticate with imap.login
            imap.login(login, password)
        rescue Net::IMAP::NoResponseError => e
            retVal = nil
        end
        return retVal
    end

    def auth_method_name
        "IMAP" 
    end
end
    (1-6/6)