ADD aaa-12 配置管理-用户锁定功能配置

RCA:
SOL:
修改人:chenling
检视人:
This commit is contained in:
ChenLing 2019-07-02 17:16:43 +08:00
parent a08b3e8b2a
commit f93af5d8a1
4 changed files with 166 additions and 6 deletions
Platform/user/configm/config-server
include
localportal_config
userlock_config

View File

@ -14,10 +14,9 @@
#define USER_MANAGER_CONFIG_MODULE 0x00000002
/*PORTAL SERVER CONFIG */
#define PORTAL_CONFIG_MODULE 0x00000003
#define LOCALAUTH_CONFIG_MODULE 0x00000003
/* AUTHFREE CONFIG*/
#define AUTHFREE_CONFIG_MODULE 0x00000004
@ -27,9 +26,12 @@
#define USER_MANAGER_CONFIG_GROUP (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|1)
#define USER_MANAGER_CONFIG_USER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|2)
#define PORTALSERVER_CONFIG (uint64)((uint64)PORTAL_CONFIG_MODULE<<32|1)
#define PORTALSERVER_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1)
#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2)
#define USERLOCK_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|3)
#define JUMPPAGE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|4)
#define AUTHFREE_CONFIG (uint64)((uint64)AUTHFREE_CONFIG_MODULE<<32|1)
/*
1ID
2,
@ -83,6 +85,27 @@
freeauth_config_get, \
freeauth_config_get_all \
},\
{\
USERLOCK_CONFIG, \
CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \
FALSE, \
FALSE, \
userlock_config_chk, \
userlock_config_proc, \
userlock_config_get, \
userlock_config_get_all \
},\
{\
JUMPPAGE_CONFIG, \
CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \
FALSE, \
FALSE, \
jumppage_config_chk, \
jumppage_config_proc, \
jumppage_config_get, \
jumppage_config_get_all \
},\
\
}
typedef ret_code (*cm_config_chk)(uint source, uint config_type,

View File

@ -0,0 +1,45 @@
#ifndef USERLOCK_H_
#define USERLOCK_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include "../../../../common/rpc/rpc_common.h"
#define FAIL_MIN_NUM 0 /*失败次数的最小值*/
#define LOCK_MIN_TIME 0 /*锁定的最小时间 */
#define HORIZON_MIN_VALUE 0 /*认证时间范围的最小值 */
/*配置消息 */
typedef struct {
time_t logintime;
int timehorizon;
int failcount;
int locktime;
}userlock_configure_t;
/*全局变量初始化 失败为1 成功为0*/
int Init(userlock_configure_t *userlock);
/*判断锁定配置信息是否有效时间范围大于0失败的次数大于0锁定时间大于0 */
ret_code userlock_config_chk(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
/*系统管理模块将数据内容IP地址、端口号发送给web server */
int userlock_config_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
#endif

View File

@ -120,7 +120,7 @@ int portalserver_config_proc(uint source, uint config_type,
inet_ntop(AF_INET, (void *)&struct_portal->ip, str, 32);
char *ip_addr = str;
rpc_log_info("portalserver configure: ip: %s port: %d\n",
struct_portal->ip, struct_portal->port);
ip_addr, struct_portal->port);
/*将配置信息发送到web server */

View File

@ -0,0 +1,92 @@
#include "../../../../common/rpc/rpc.h"
#include "../include/parsefile.h"
#include "../include/configm.h"
#include "../../../netlink_uapi/libnetlinku.h"
#include <cjson/cJSON.h>
#include "../../../../../Common/s2j/s2j.h"
#include "../../../../../Common/commuapinl.h"
#include "../include/userlock.h"
/*全局变量,存放锁定功能的信息 */
userlock_configure_t *userlock;
/*全局变量初始化 失败为1 成功为0*/
int Init(userlock_configure_t *userlock)
{
userlock = (userlock_configure_t *)malloc(sizeof * userlock);
if (NULL == userlock)
{
return 1;
}
return 0;
}
/*判断锁定配置信息是否有效时间范围大于0失败的次数大于0锁定时间大于0 */
ret_code userlock_config_chk(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len)
{
ret_code ret = RET_OK;
userlock_configure_t *struct_userlock;
struct_userlock = (userlock_configure_t *)input;
if(input_len < sizeof(userlock_configure_t) )
{
ret = RET_INPUTERR;
}
/*配置的用户失败次数如果小于0则配置错误 */
if(struct_userlock->failcount < FAIL_MIN_NUM )
{
ret = RET_ERR;
printf("userlock configure error\n");
}
/*配置的用户锁定时间如果小于0则配置错误 */
if(struct_userlock->locktime < LOCK_MIN_TIME )
{
ret = RET_ERR;
printf("locktime configure error\n");
}
/*配置的用户认证时间范围如果小于0则配置错误 */
if(struct_userlock->timehorizon < HORIZON_MIN_VALUE )
{
ret = RET_ERR;
printf("timehorizon configure error\n");
}
ASSERT_RET(ret);
return RET_OK;
}
/*系统管理模块将数据内容IP地址、端口号发送给web server */
int userlock_config_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len)
{
ret_code ret = RET_OK;
userlock_configure_t *struct_userlock;
struct_userlock = (userlock_configure_t *)input;
rpc_log_info("userlock configure: 登录时间: %d 用户认证失败次数: %d 用户认证的时间范围: %d 用户锁定时间: %d\n",
struct_userlock->logintime, struct_userlock->failcount,
struct_userlock->timehorizon, struct_userlock->locktime);
/*将配置信息struct_userlock发送到数据库 */
/*把本地Portal server的配置信息存入全局变量 */
userlock = struct_userlock;
return 0;
}