1
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
3
#include "imap-common.h"
5
#include "imap-commands.h"
6
#include "imap-quote.h"
7
#include "imap-urlauth.h"
9
bool cmd_genurlauth(struct client_command_context *cmd)
11
const struct imap_arg *args;
15
if (cmd->client->urlauth_ctx == NULL) {
16
client_send_command_error(cmd, "URLAUTH disabled.");
20
if (!client_read_args(cmd, 0, 0, &args))
23
response = t_str_new(1024);
24
str_append(response, "* GENURLAUTH");
26
const char *url_rump, *mechanism, *url, *error;
28
if (IMAP_ARG_IS_EOL(args))
30
if (!imap_arg_get_astring(args++, &url_rump) ||
31
!imap_arg_get_atom(args++, &mechanism)) {
32
client_send_command_error(cmd, "Invalid arguments.");
36
ret = imap_urlauth_generate(cmd->client->urlauth_ctx,
37
mechanism, url_rump, &url, &error);
40
client_send_internal_error(cmd);
42
client_send_command_error(cmd, error);
46
str_append_c(response, ' ');
47
imap_append_astring(response, url);
50
client_send_line(cmd->client, str_c(response));
51
client_send_tagline(cmd, "OK GENURLAUTH completed.");