oauth2.h revision bcb4e51a409d94ae670de96afb8483a4f7855294
/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
#ifndef OAUTH2_H
#define OAUTH2_H
#include "net.h"
struct oauth2_request;
struct oauth2_field {
const char *name;
const char *value;
};
struct oauth2_settings {
struct http_client *client;
/* GET tokeninfo from this URL, token is appended to URL
const char *tokeninfo_url;
/* GET more information from this URL, uses Bearer authentication */
const char *introspection_url;
/* POST refresh here, needs refresh token and client_* settings */
const char *refresh_url;
const char *client_id;
const char *client_secret;
enum {
unsigned int timeout_msecs;
/* Should X-Dovecot-Auth-* headers be sent */
bool send_auth_headers;
};
struct oauth2_token_validation_result {
const char *error;
bool success:1;
bool valid:1;
};
struct oauth2_introspection_result {
const char *error;
bool success:1;
};
struct oauth2_refresh_result {
const char *bearer_token;
const char *error;
bool success:1;
};
struct oauth2_request_input {
const char *token;
const char *service;
};
typedef void
oauth2_token_validation_callback_t(struct oauth2_token_validation_result*, void*);
typedef void
oauth2_introspection_callback_t(struct oauth2_introspection_result*, void*);
typedef void
oauth2_refresh_callback_t(struct oauth2_refresh_result*, void*);
bool oauth2_valid_token(const char *token);
struct oauth2_request*
const struct oauth2_request_input *input,
void *context);
struct oauth2_request*
const struct oauth2_request_input *input,
void *context);
struct oauth2_request*
const struct oauth2_request_input *input,
void *context);
/* abort without calling callback, use this to cancel the request */
void oauth2_request_abort(struct oauth2_request **);
#endif