Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: disabled authentication! #12

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ def load_guilds_latest_date_df():

logging.basicConfig(level=logging.INFO)
st.subheader("TogetherCrew's Amin Panel")
with open("config.yaml") as file:
config = yaml.load(file, Loader=SafeLoader)

authenticator = Authenticate(
config["credentials"],
config["cookie"]["name"],
config["cookie"]["key"],
config["cookie"]["expiry_days"],
config["preauthorized"],
)
name, authentication_status, username = authenticator.login()

if authentication_status:
authenticator.logout("Logout", "main")
st.write(f"Welcome *{name}*")
# st.title('Some content')
load_guilds_latest_date_df()
elif authentication_status is False:
st.error("Username/password is incorrect")
elif authentication_status is None:
st.warning("Please enter your username and password")
# with open("config.yaml") as file:
# config = yaml.load(file, Loader=SafeLoader)

# authenticator = Authenticate(
# config["credentials"],
# config["cookie"]["name"],
# config["cookie"]["key"],
# config["cookie"]["expiry_days"],
# config["preauthorized"],
# )
# name, authentication_status, username = authenticator.login()

# if authentication_status:
# authenticator.logout("Logout", "main")
# st.write(f"Welcome *{name}*")
# # st.title('Some content')
load_guilds_latest_date_df()
# elif authentication_status is False:
# st.error("Username/password is incorrect")
# elif authentication_status is None:
# st.warning("Please enter your username and password")
Comment on lines +41 to +61
Copy link

@coderabbitai coderabbitai bot Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Issue: Do not disable authentication!

Removing the authentication mechanism exposes the guilds' data to unauthorized access, which is a major security vulnerability. This could lead to data breaches, privacy violations, and reputational damage.

Disabling authentication goes against security best practices and compliance requirements. It is strongly advised to restore the authentication mechanism and ensure proper access controls are in place.

Revert the changes that disable authentication by removing the comments from the authentication-related code:

-# with open("config.yaml") as file:
-#     config = yaml.load(file, Loader=SafeLoader)
+with open("config.yaml") as file:
+    config = yaml.load(file, Loader=SafeLoader)

-# authenticator = Authenticate(
-#     config["credentials"],
-#     config["cookie"]["name"],
-#     config["cookie"]["key"], 
-#     config["cookie"]["expiry_days"],
-#     config["preauthorized"],
-# )
-# name, authentication_status, username = authenticator.login()
+authenticator = Authenticate(
+    config["credentials"],
+    config["cookie"]["name"],
+    config["cookie"]["key"],
+    config["cookie"]["expiry_days"],
+    config["preauthorized"],
+)
+name, authentication_status, username = authenticator.login()

-# if authentication_status:
-#     authenticator.logout("Logout", "main")
-#     st.write(f"Welcome *{name}*")
-#     # st.title('Some content')
+if authentication_status:
+    authenticator.logout("Logout", "main")
+    st.write(f"Welcome *{name}*")
+    # st.title('Some content')
    load_guilds_latest_date_df()
-# elif authentication_status is False:
-#     st.error("Username/password is incorrect")
-# elif authentication_status is None:
-#     st.warning("Please enter your username and password")
+elif authentication_status is False:
+    st.error("Username/password is incorrect") 
+elif authentication_status is None:
+    st.warning("Please enter your username and password")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# with open("config.yaml") as file:
# config = yaml.load(file, Loader=SafeLoader)
# authenticator = Authenticate(
# config["credentials"],
# config["cookie"]["name"],
# config["cookie"]["key"],
# config["cookie"]["expiry_days"],
# config["preauthorized"],
# )
# name, authentication_status, username = authenticator.login()
# if authentication_status:
# authenticator.logout("Logout", "main")
# st.write(f"Welcome *{name}*")
# # st.title('Some content')
load_guilds_latest_date_df()
# elif authentication_status is False:
# st.error("Username/password is incorrect")
# elif authentication_status is None:
# st.warning("Please enter your username and password")
with open("config.yaml") as file:
config = yaml.load(file, Loader=SafeLoader)
authenticator = Authenticate(
config["credentials"],
config["cookie"]["name"],
config["cookie"]["key"],
config["cookie"]["expiry_days"],
config["preauthorized"],
)
name, authentication_status, username = authenticator.login()
if authentication_status:
authenticator.logout("Logout", "main")
st.write(f"Welcome *{name}*")
# st.title('Some content')
load_guilds_latest_date_df()
elif authentication_status is False:
st.error("Username/password is incorrect")
elif authentication_status is None:
st.warning("Please enter your username and password")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, we're disabling it but in future it will be added.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amindadgar, understood. Thank you for the clarification.

(ಥ﹏ಥ)


Learnings added
Learnt from: amindadgar
PR: TogetherCrew/admin-panel#12
File: app.py:41-61
Timestamp: 2024-09-16T07:37:12.042Z
Learning: Authentication is temporarily disabled in `app.py` and will be re-enabled in the future.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

2 changes: 1 addition & 1 deletion utils/process_guild_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def process_guild_data(
"""
platform_id = str(platform_document["_id"])
guild_id = platform_document["metadata"]["id"]
utils = MongoUtils(guild_id)
utils = MongoUtils(platform_id)

guild_name = platform_document["metadata"]["name"]
connected_at = platform_document["connectedAt"]
Expand Down
Loading