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