Skip to content

Commit 0bc6314

Browse files
Merge branch 'develop'
2 parents 14a4017 + c8b3c26 commit 0bc6314

File tree

164 files changed

+5605
-1208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+5605
-1208
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
22
commit_id=${BUILD_ID}-$(git rev-parse --short HEAD)
33
echo $commit_id> commit_id.txt
4-
docker run \
5-
--rm \
6-
-e SONAR_HOST_URL="https://sonarqube.anuvaad.org" \
7-
-e SONAR_LOGIN=$sonar_key \
8-
-v "${PWD}:/usr/src" \
9-
sonarsource/sonar-scanner-cli \
10-
-Dsonar.projectKey=$image_name \
11-
-Dsonar.sonar.projectName="$image_name" \
12-
-Dsonar.sonar.projectVersion=1.0 \
13-
-Dsonar.sonar.sourceEncoding=UTF-8
4+
# docker run \
5+
# --rm \
6+
# -e SONAR_HOST_URL="https://sonarqube.anuvaad.org" \
7+
# -e SONAR_LOGIN=$sonar_key \
8+
# -v "${PWD}:/usr/src" \
9+
# sonarsource/sonar-scanner-cli \
10+
# -Dsonar.projectKey=$image_name \
11+
# -Dsonar.sonar.projectName="$image_name" \
12+
# -Dsonar.sonar.projectVersion=1.0 \
13+
# -Dsonar.sonar.sourceEncoding=UTF-8
1414
docker build -t anuvaadio/$image_name:$commit_id .
1515
docker login -u $dockerhub_user -p $dockerhub_pass
1616
docker push anuvaadio/$image_name:$commit_id

anuvaad-api/anuvaad-metrics/anuvaad-org-judgement-count/src/models/language.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"code": "IITB"
7575
},
7676
{
77-
"code": "CHATTISGARH"
77+
"code": "CHHATTISGARH"
7878
},
7979
{
8080
"code": "NEPAL"

anuvaad-api/anuvaad-metrics/anuvaad-org-judgement-count/src/models/stats.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ def get_time_frame_for_analytics(self):
262262
return from_date, end_date
263263

264264
def file_validation(self):
265-
file_name1 = config.DAILY_CRON_FILE_NAME1
266-
file_name2 = config.DAILY_CRON_FILE_NAME2
265+
file_name1 = config.WEEKLY_CRON_FILE_NAME1
266+
file_name2 = config.WEEKLY_CRON_FILE_NAME2
267267
stats_file_copy = config.STATS_FILE_COPY
268268
# file_name2 = "/home/sriharimn/Downloads/language_wise_JUD_STATS2.csv"
269269
# file_name1 = "/home/sriharimn/Downloads/language_wise_JUD_STATS1.csv"
@@ -277,10 +277,10 @@ def file_validation(self):
277277
df.dropna(subset=['orgID'], inplace=True)
278278
# result = df1.merge(df, indicator=True, how="right")
279279
result = df.sort_values(by=["orgID"], ascending=True)
280-
# mask = result["orgID"].isin(
281-
# ["ANUVAAD", "TARENTO_TESTORG", "NONMT", "ECOMMITTEE "]
282-
# )
283-
# result = result[~mask]
280+
mask = result["orgID"].isin(
281+
["ANUVAAD", "TARENTO_TESTORG", "NONMT", "ECOMMITTEE "]
282+
)
283+
result = result[~mask]
284284
else:
285285
df = pd.read_csv(file_name1)
286286
df1 = pd.read_csv(file_name2)

anuvaad-api/anuvaad-metrics/anuvaad-org-judgement-count/src/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Flask-Cors==3.0.10
2-
# anuvaad_auditor==0.1.6
32
anuvaad-auditor==1.0.0
43
Flask-RESTful==0.3.8
54
six==1.15.0

anuvaad-api/anuvaad-metrics/anuvaad-org-judgement-count/src/services/crons.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ def get_trans_user_data_from_db_weekly_crn():
2828
users = config.EMAIL_NOTIFIER
2929
log_info("fetch data started", MODULE_CONTEXT)
3030
# filename = uuid.uuid4().hex
31+
stats_file = config.STATS_FILE
3132
weekly_cron_file_name1 = config.WEEKLY_CRON_FILE_NAME1
3233
weekly_cron_file_name2 = config.WEEKLY_CRON_FILE_NAME2
33-
# daily_cron_file_name1 = config.DAILY_CRON_FILE_NAME1
34-
# daily_cron_file_name2 = config.DAILY_CRON_FILE_NAME2
35-
stats_file = config.STATS_FILE
36-
# stats_file_copy = config.STATS_FILE_COPY
34+
daily_cron_file_name1 = config.DAILY_CRON_FILE_NAME1
35+
daily_cron_file_name2 = config.DAILY_CRON_FILE_NAME2
3736
# file_save = str(filename)[:-10]+'_USER_WISE_JUD_Org_level_Statistics.csv'
3837
if os.path.exists(
3938
config.DOWNLOAD_FOLDER + "/" + weekly_cron_file_name1
40-
) and os.path.exists(config.DOWNLOAD_FOLDER + "/" + weekly_cron_file_name2
39+
) and os.path.exists(config.DOWNLOAD_FOLDER + "/" + weekly_cron_file_name2
4140
) and os.path.exists(config.DOWNLOAD_FOLDER + "/" + stats_file):
4241
os.remove(config.DOWNLOAD_FOLDER + "/" + weekly_cron_file_name1)
4342
os.remove(config.DOWNLOAD_FOLDER + "/" + weekly_cron_file_name2)
4443
os.remove(config.DOWNLOAD_FOLDER + "/" + stats_file)
44+
# os.remove(config.DOWNLOAD_FOLDER + "/" + daily_cron_file_name1)
45+
# os.remove(config.DOWNLOAD_FOLDER + "/" + daily_cron_file_name2)
4546
else:
4647
msg = generate_email_notification(
4748
users, "could not get the data files not found"
@@ -85,7 +86,7 @@ def get_trans_user_data_from_db_weekly_crn():
8586
result2 = result_save_doc.merge(result_ch_doc,indicator=False,how="right")
8687
result2.to_csv(config.DOWNLOAD_FOLDER + "/" + stats_file)
8788

88-
log_info(f"Data written into files {weekly_cron_file_name1,weekly_cron_file_name2}",MODULE_CONTEXT,)
89+
log_info(f"Data written into files {weekly_cron_file_name1,weekly_cron_file_name2,stats_file}",MODULE_CONTEXT,)
8990

9091
return
9192
except Exception as e:
@@ -95,7 +96,7 @@ def get_trans_user_data_from_db_weekly_crn():
9596
)
9697
send_email(msg)
9798
log_exception(
98-
"Generated alert email in exception weekly cron job : {}".format(str(e)),
99+
"Generated alert email in exception cron job : {}".format(str(e)),
99100
MODULE_CONTEXT,
100101
e,
101102
)

anuvaad-api/anuvaad-user-management/user-management/user-management/config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@
1414
PORT = 5001
1515
ENABLE_CORS = False
1616

17+
# redis config
18+
REDIS_SERVER_PREFIX = os.environ.get('REDIS_PREFIX', 'redis')
19+
REDIS_SERVER_HOST = os.environ.get('REDIS_URL', 'localhost')
20+
REDIS_SERVER_PORT = os.environ.get('REDIS_PORT', 6379)
21+
ACTIVE_USERS_EXP_TIME = 2 * 60 # in seconds
22+
1723
#mongodb-configs
1824
MONGO_DB_SCHEMA = os.environ.get('MONGO_DB_IDENTIFIER', 'usermanagement')
1925
USR_MONGO_COLLECTION = os.environ.get('UMS_USR_COLLECTION', 'sample')
26+
MFA_MONGO_COLLECTION = os.environ.get('UMS_MFA_COLLECTION', 'mfa')
2027
USR_TOKEN_MONGO_COLLECTION = os.environ.get('UMS_USR_TOKEN_COLLECTION', 'usertokens')
2128
USR_TEMP_TOKEN_MONGO_COLLECTION = os.environ.get('UMS_USR_TEMP_TOKEN_COLLECTION', 'usertemptoken')
2229
USR_ORG_MONGO_COLLECTION = os.environ.get('UMS_ORG_COLLECTION', 'organization')
@@ -52,6 +59,7 @@
5259
ROLE_CODES_URL = os.environ.get('UMS_ROLE_CODES_URL','https://raw.githubusercontent.com/project-anuvaad/anuvaad/master/anuvaad-api/anuvaad-zuul-api-gw/dev-configs/roles.json')
5360
ROLE_CODES_DIR_PATH = os.environ.get('UMS_ROLE_DIR_PATH','/app/configs/') #'/home/jainy/Documents/Anuvaad_local_files/usrmgmt/'
5461
ROLE_CODES_FILE_NAME = os.environ.get('UMS_FILE_NAME','roles.json')
62+
ONE_ROLE_PER_ORG_LIST = str(os.environ.get('','ADMIN REVIEWER')).split()
5563

5664
#gmail server configs
5765
MAIL_SETTINGS = {
@@ -68,3 +76,11 @@
6876
#React-app base url
6977
BASE_URL = os.environ.get('REACT_APP_BASE_URL','https://developers.anuvaad.org/')
7078

79+
# MFA configs
80+
MFA_ENABLED = bool(os.environ.get("MFA_ENABLED",False))
81+
MFA_SUPPORTED_TYPES = ['TOTP','HOTP']
82+
MFA_ISSUER = os.environ.get("MFA_ISSUER", "Anuvaad Folks")
83+
MFA_TOTP_INTERVAL = os.environ.get("MFA_TOTP_INTERVAL", 30) # only 30 is supported for google and microsoft auth apps
84+
MFA_HOTP_COUNTER = os.environ.get("MFA_HOTP_COUNTER", 15)
85+
MFA_SKIP_ROLES = [SUPER_ADMIN_ROLE_KEY]
86+
MFA_EXPIRATION_TIME = int(os.environ.get("MFA_HOTP_COUNTER", 10 * 60)) # in seconds
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .connection_manager import get_db,User_management_db
1+
from .connection_manager import get_db,User_management_db, get_active_users_redis

anuvaad-api/anuvaad-user-management/user-management/user-management/db/connection_manager.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from config import MONGO_SERVER_HOST
2-
from config import MONGO_DB_SCHEMA
1+
from config import MONGO_SERVER_HOST, REDIS_SERVER_HOST
2+
from config import MONGO_DB_SCHEMA, REDIS_SERVER_PORT
33
from utilities import MODULE_CONTEXT
44
from pymongo import MongoClient
55
from anuvaad_auditor.loghandler import log_info, log_exception
66
from flask import g
7+
import redis
78

89
client = MongoClient(MONGO_SERVER_HOST)
910

@@ -32,4 +33,8 @@ def get_mongo_instance(self, db,collection):
3233
# else:
3334
db_instance = db
3435
return db_instance[collection]
35-
36+
37+
def get_active_users_redis():
38+
if 'redisdb' not in g:
39+
g.redisdb = redis.Redis(host=REDIS_SERVER_HOST, port=REDIS_SERVER_PORT, db=10)
40+
return g.redisdb

anuvaad-api/anuvaad-user-management/user-management/user-management/models/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
from .response import CustomResponse
44
from .status import Status
55
from .user_org import UserOrganizationModel
6-
from .extension import ExtensionModel
6+
from .extension import ExtensionModel
7+
from .mfa import MFAModel

0 commit comments

Comments
 (0)