Giter Club home page Giter Club logo

Comments (4)

foxcpp avatar foxcpp commented on May 15, 2024

Another thing is that users may want to have different storage associated with accounts coming from different auth. backends. Currently, authentication is fully separate from storage and we have the concept of "auth account" and "storage account". This makes it difficult to build some sort of association.

We can allow authentication modules to return some kind of "association tag", which could then be consumed by storage backend.
There are multiple ways to implement such association tags. Depending on the level of abstraction you want them to be on.

SMTP, Pipeline: Allow branching directives to inspect association tag created by authentication provider (using syntax described in #32):

if $authsource = pam {
}

Approach A: Extend authentication provider interface:

type AuthProvider interface {
  CheckPlain(username, password) (associationTag string, err error)
}

Extend storage IMAP interface in similar way:

type StorageBackend interface {
  GetUser(assocationTag, username, password string) (backend.User, error)
}

Then implement multi storage backend and authentication provider capable of making use of these association tags for purposes of dispatching.

from maddy.

foxcpp avatar foxcpp commented on May 15, 2024

Approach B: Move dispatching logic to the upper level.

Do all dispatching at the endpoint (or pipeline) module level, using auth. provider instance names as "association tags".

imap ... {
  auth multi local_users {
      user pam
      pass virtual { file /var/lib/maddy/local-passwd }
  }
  auth multi virtual_users {
      user virtual { file /var/lib/maddy/virtual-users }
      pass virtual { file /var/lib/maddy/virtual-passwd }
  }

  storage {
    auth local_users maildir { root /var/spool/ }
    auth virtual_users sql
  }
}
submission ... {
  auth multi local_users {
      user pam
      pass virtual { file /var/lib/maddy/local-passwd }
  }
  auth multi virtual_users {
      user virtual { file /var/lib/maddy/virtual-users }
      pass virtual { file /var/lib/maddy/virtual-passwd }
  }

  if $auth = virtual_users {
    ...
  } 
}

Side-note: Common auth expressions can be factored out into a snippet:

(auth) {
  auth multi local_users {
      user pam
      pass virtual { file /var/lib/maddy/local-passwd }
  }
  auth multi virtual_users {
      user virtual { file /var/lib/maddy/virtual-users }
      pass virtual { file /var/lib/maddy/virtual-passwd }
  }
}

Or we might want to allow specificing auth directive at top level.

Okay, I think Approach B is more clear and Approach A basically ruins all existing abstractions, while B builds on them.

from maddy.

foxcpp avatar foxcpp commented on May 15, 2024
multi instance_name {
 user pam
 user virtual { file /etc/maddy/userlist }
 pass virtual { file /etc/maddy/passwd }
}

Side note: Not all PAM modules differentiate between "user doesn't exist" and "invalid password" so this setup may be problematic in reality.

from maddy.

foxcpp avatar foxcpp commented on May 15, 2024
  auth multi local_users {
      user pam
      pass virtual { file /var/lib/maddy/local-passwd }
  }
  auth multi virtual_users {
      user virtual { file /var/lib/maddy/virtual-users }
      pass virtual { file /var/lib/maddy/virtual-passwd }
  }

Also this needs extension of config.Map to allow multiple values for directives.

from maddy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.