1 /*
2 Copyright (c) 2015-2020 Roger Light <roger@atchoo.org>
3 
4 All rights reserved. This program and the accompanying materials
5 are made available under the terms of the Eclipse Public License 2.0
6 and Eclipse Distribution License v1.0 which accompany this distribution.
7 
8 The Eclipse Public License is available at
9    https://www.eclipse.org/legal/epl-2.0/
10 and the Eclipse Distribution License is available at
11   http://www.eclipse.org/org/documents/edl-v10.php.
12 
13 SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
14 
15 Contributors:
16    Roger Light - initial implementation and documentation.
17 */
18 
19 /* This is a skeleton authentication and access control plugin that simply defers all checks. */
20 
21 #include <stdio.h>
22 
23 #include "mosquitto_broker.h"
24 #include "mosquitto_plugin.h"
25 #include "mosquitto.h"
26 
mosquitto_auth_plugin_version(void)27 int mosquitto_auth_plugin_version(void)
28 {
29 	return 4;
30 }
31 
mosquitto_auth_plugin_init(void ** user_data,struct mosquitto_opt * auth_opts,int auth_opt_count)32 int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
33 {
34 	return MOSQ_ERR_SUCCESS;
35 }
36 
mosquitto_auth_plugin_cleanup(void * user_data,struct mosquitto_opt * auth_opts,int auth_opt_count)37 int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
38 {
39 	return MOSQ_ERR_SUCCESS;
40 }
41 
mosquitto_auth_security_init(void * user_data,struct mosquitto_opt * auth_opts,int auth_opt_count,bool reload)42 int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
43 {
44 	return MOSQ_ERR_SUCCESS;
45 }
46 
mosquitto_auth_security_cleanup(void * user_data,struct mosquitto_opt * auth_opts,int auth_opt_count,bool reload)47 int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
48 {
49 	return MOSQ_ERR_SUCCESS;
50 }
51 
mosquitto_auth_acl_check(void * user_data,int access,struct mosquitto * client,const struct mosquitto_acl_msg * msg)52 int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg)
53 {
54 	printf("mosquitto_acl_check(u:%s)\n", mosquitto_client_username(client));
55 	return MOSQ_ERR_PLUGIN_DEFER;
56 }
57 
mosquitto_auth_unpwd_check(void * user_data,struct mosquitto * client,const char * username,const char * password)58 int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password)
59 {
60 	return MOSQ_ERR_PLUGIN_DEFER;
61 }
62 
mosquitto_auth_psk_key_get(void * user_data,struct mosquitto * client,const char * hint,const char * identity,char * key,int max_key_len)63 int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len)
64 {
65 	return MOSQ_ERR_PLUGIN_DEFER;
66 }
67 
68