f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#ifndef IMAP_URLAUTH_H
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#define IMAP_URLAUTH_H
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
009217abb57a24a4076092e8e4e165545747839eStephan Bosch#include "net.h"
009217abb57a24a4076092e8e4e165545747839eStephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#define IMAP_URLAUTH_SOCKET_NAME "imap-urlauth"
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct imap_url;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct imap_msgpart_url;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct imap_urlauth_context;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct imap_urlauth_config {
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *url_host;
009217abb57a24a4076092e8e4e165545747839eStephan Bosch in_port_t url_port;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *socket_path;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *session_id;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch /* the user who is requesting access to URLAUTHs */
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *access_user;
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch /* ... is using this service (i.e. imap or submission) */
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch const char *access_service;
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch /* ... represents these applications */
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *const *access_applications;
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch /* ... is anonymous? */
6541da94741ea43514cdac3dd2ebbcf839ffb783Stephan Bosch bool access_anonymous;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch};
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
4abdade2cb09266ea3d063d5cb6893cb0583f20eTimo Sirainenstruct imap_urlauth_context *
4abdade2cb09266ea3d063d5cb6893cb0583f20eTimo Sirainenimap_urlauth_init(struct mail_user *user,
4abdade2cb09266ea3d063d5cb6893cb0583f20eTimo Sirainen const struct imap_urlauth_config *config);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschvoid imap_urlauth_deinit(struct imap_urlauth_context **_uctx);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschint imap_urlauth_generate(struct imap_urlauth_context *uctx,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *mechanism, const char *rumpurl,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char **urlauth_r, const char **error_r);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschbool imap_urlauth_check(struct imap_urlauth_context *uctx,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct imap_url *url, bool ignore_unknown_access,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char **error_r);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschint imap_urlauth_fetch_parsed(struct imap_urlauth_context *uctx,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct imap_url *url,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct imap_msgpart_url **mpurl_r,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch enum mail_error *error_code_r,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char **error_r);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschint imap_urlauth_fetch(struct imap_urlauth_context *uctx,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const char *urlauth, struct imap_msgpart_url **mpurl_r,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch enum mail_error *error_code_r, const char **error_r);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschint imap_urlauth_reset_mailbox_key(struct imap_urlauth_context *uctx,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct mailbox *box);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschint imap_urlauth_reset_all_keys(struct imap_urlauth_context *uctx);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#endif