Skip to content
Snippets Groups Projects
Commit 4c295056 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[*] Refactored some

parent 9a52204d
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project (dap_server_http_db_auth) project (dap_server_http_db_auth)
set(AUTH_SRCS db_auth.c) file(GLOB DAP_SERVER_HTTP_DB_AUTH_SOURCES src/*.c)
file(GLOB DAP_SERVER_HTTP_DB_AUTH_HEADERS include/*.h)
add_library(${PROJECT_NAME} STATIC ${AUTH_SRCS}) add_library(${PROJECT_NAME} STATIC ${DAP_SERVER_HTTP_DB_AUTH_SOURCES} ${DAP_SERVER_HTTP_DB_AUTH_HEADERS})
target_link_libraries(${PROJECT_NAME} dap_core target_link_libraries(${PROJECT_NAME} dap_crypto dap_stream dap_server_http_db )
dap_crypto dap_http_server dap_enc_server
dap_stream dap_http_server_db ) target_include_directories(${PROJECT_NAME} PUBLIC include)
target_include_directories(${PROJECT_NAME} PRIVATE src)
/* /*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc Copyright (c) 2017-2019 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved. All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project This file is part of DAP (Deus Applications Prototypes) the open source project
...@@ -18,9 +18,7 @@ ...@@ -18,9 +18,7 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#ifndef STREAM_AUTH_H
#define STREAM_AUTH_H
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#include "uthash.h" #include "uthash.h"
...@@ -46,41 +44,39 @@ typedef struct db_auth_info{ ...@@ -46,41 +44,39 @@ typedef struct db_auth_info{
UT_hash_handle hh; // makes this structure hashable with UTHASH library UT_hash_handle hh; // makes this structure hashable with UTHASH library
} db_auth_info_t; } db_auth_info_t;
extern int db_auth_init(const char* db_name); int db_auth_init(const char* db_name);
extern void db_auth_deinit(void); void db_auth_deinit(void);
extern db_auth_info_t* db_auth_info_by_cookie(const char * cookie); db_auth_info_t* db_auth_info_by_cookie(const char * cookie);
extern db_auth_info_t* db_search_cookie_in_db(const char * cookie); db_auth_info_t* db_search_cookie_in_db(const char * cookie);
extern int db_auth_login(const char* login, const char* password, int db_auth_login(const char* login, const char* password,
const char* domain, db_auth_info_t** ai); const char* domain, db_auth_info_t** ai);
extern db_auth_info_t * db_auth_register(const char *user,const char *password, db_auth_info_t * db_auth_register(const char *user,const char *password,
const char *domain, const char * first_name, const char *domain, const char * first_name,
const char* last_name, const char * email, const char* last_name, const char * email,
const char * device_type, const char *app_version, const char * device_type, const char *app_version,
const char *hostaddr, const char *sys_uuid); const char *hostaddr, const char *sys_uuid);
extern db_auth_info_t * db_auth_register_channel(const char* name_channel, const char* domain, db_auth_info_t * db_auth_register_channel(const char* name_channel, const char* domain,
const char* password); const char* password);
extern bool exist_user_in_db(const char* user); bool exist_user_in_db(const char* user);
bool db_auth_user_change_password(const char* user, const char* password,
extern bool db_auth_user_change_password(const char* user, const char* password,
const char* new_password); const char* new_password);
extern bool db_auth_change_password(const char *user, const char* new_password); bool db_auth_change_password(const char *user, const char* new_password);
extern bool check_user_password(const char* user, const char* password); bool check_user_password(const char* user, const char* password);
extern void db_auth_http_proc(enc_http_delegate_t *dg, void * arg); void db_auth_http_proc(enc_http_delegate_t *dg, void * arg);
extern void db_auth_traffic_track_callback(dap_server_t *srv); void db_auth_traffic_track_callback(dap_server_t *srv);
/// Check user data for correct input. /// Check user data for correct input.
/// @param before_parsing Line size before parsing. /// @param before_parsing Line size before parsing.
/// @param after_parsing Line size after parsing. /// @param after_parsing Line size after parsing.
/// @return Returns true if user data is entered correctly /// @return Returns true if user data is entered correctly
/// (there are 2 separator spaces), otherwise false. /// (there are 2 separator spaces), otherwise false.
extern inline bool check_user_data_for_space(size_t before_parsing, size_t after_parsing); inline bool check_user_data_for_space(size_t before_parsing, size_t after_parsing);
#endif
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
#include "dap_enc_http.h" #include "dap_enc_http.h"
#include "dap_enc_base64.h" #include "dap_enc_base64.h"
#include "dap_server.h" #include "dap_server.h"
#include "../db/db_core.h" #include "db_core.h"
#include "db_auth.h" #include "db_auth.h"
#include "http_status_code.h" #include "http_status_code.h"
#include "mongoc.h" #include <mongoc.h>
#define LOG_TAG "db_auth" #define LOG_TAG "db_auth"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment