1 #include <stdio.h>
2 #include <string.h>
3 #include <mosquitto.h>
4 #include <mosquitto_broker.h>
5 #include <mosquitto_plugin.h>
6 
mosquitto_auth_plugin_version(void)7 int mosquitto_auth_plugin_version(void)
8 {
9 	return MOSQ_AUTH_PLUGIN_VERSION;
10 }
11 
mosquitto_auth_plugin_init(void ** user_data,struct mosquitto_opt * auth_opts,int auth_opt_count)12 int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
13 {
14 	return MOSQ_ERR_SUCCESS;
15 }
16 
mosquitto_auth_plugin_cleanup(void * user_data,struct mosquitto_opt * auth_opts,int auth_opt_count)17 int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
18 {
19 	return MOSQ_ERR_SUCCESS;
20 }
21 
mosquitto_auth_security_init(void * user_data,struct mosquitto_opt * auth_opts,int auth_opt_count,bool reload)22 int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
23 {
24 	return MOSQ_ERR_SUCCESS;
25 }
26 
mosquitto_auth_security_cleanup(void * user_data,struct mosquitto_opt * auth_opts,int auth_opt_count,bool reload)27 int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
28 {
29 	return MOSQ_ERR_SUCCESS;
30 }
31 
mosquitto_auth_acl_check(void * user_data,int access,struct mosquitto * client,const struct mosquitto_acl_msg * msg)32 int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg)
33 {
34 	return MOSQ_ERR_PLUGIN_DEFER;
35 }
36 
mosquitto_auth_unpwd_check(void * user_data,struct mosquitto * client,const char * username,const char * password)37 int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password)
38 {
39 	if(!strcmp(username, "test-username") && password && !strcmp(password, "cnwTICONIURW")){
40 		return MOSQ_ERR_SUCCESS;
41 	}else if(!strcmp(username, "readonly")){
42 		return MOSQ_ERR_SUCCESS;
43 	}else if(!strcmp(username, "test-username@v2")){
44 		return MOSQ_ERR_PLUGIN_DEFER;
45 	}else{
46 		return MOSQ_ERR_AUTH;
47 	}
48 }
49 
mosquitto_auth_psk_key_get(void * user_data,struct mosquitto * client,const char * hint,const char * identity,char * key,int max_key_len)50 int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len)
51 {
52 	return MOSQ_ERR_AUTH;
53 }
54 
55