how to find logged-in users using sorcery? - ruby-on-rails-3

Is there any way to find the currently logged-in users and delete the sessions of particular users using sorcery?
Thanks in advance.

From the documentation:
Below is a summary of the library methods. Most method names are self explaining and the rest are commented:
# activity logging
current_users
You can use current_users to iterate through all your users. To log them out have a look at reset_session.

Related

I want to delete the files once the user left the conversation in the bot framework (.netcore)

Actually, I want to delete all the files for that particular user which logged in to my BOT and once the user left the conversation. I want them all to delete as I am storing them in my wwwroot and I don't want it to store and keep it there.
Any suggestions will be helpful. how I will be able to achieve this. I am new to this?
TIA
I suggest you could try to use the ActivityHandler's OnMembersRemovedAsync method. This method provide logic for when members other than the bot leave the conversation, such as your bot's good-bye logic.
I think you could add some logic to to get the user id and delete the user according to this user ID.
More details ,you could refer to this article. About how to use this activity handler, you could refer to this welcome bot sample.

Permission linking between LDAP users groups and Django permissions (custom if possible)

Hello again every one,
I have a question: I successfully implemented django-auth-ldap, the LDAP users can request successfully my DRF API. But nows, for my projetc needs, I have to define permissions depending of the group.
Indeed, I will have like 12 groups in my app. Depending of the group, I will authorize or not the user to request a given route, BUT even if I defined the global var AUTH_LDAP_MIRROR_GROUPS = True, and saw in my database the are linked to a group (see capture):
Users in database
Groups from LDAP inserted in db thx to django-auth_ldap settings
User linked to the groups defined
But now, I have some other problems: I do not know how to implement permissions depending of the group the user belong. In fact, if a user belong to the group ServerAdministrator, I want to allow him to access to every route accessible, but I dont know where to see this in the received request in my view?
As I understood, I should implement custom permissions I should write programmatically in a User object (which should inherit from django AbstractUser)
If yes, How does it work? Should I empty my whole Database and then let django-auth-ldap insert users and it also will create the given permissions defined inside the database?
Maybe it is not clear, do not hesitate to ask questions if I can be more precise.
Kind regards.
Benjamin

Telegram Bot: Can we identify if message is from group admin?

I have added my bot to a group chat, now for few commands I need to give access only to the group admin, so is it possible to identify if the message sender is admin of the group?
I am using python-telegram-bot library
When you use getUpdates, you can see .message.chat.type is group or not.
And then use getChatMember, .result.status should be administrator or creator.
It is absolutely possible. You can use the getChatAdministrators API method (returns a list of ChatMember) to get a list of admins for a chat, or the getChatMember API method (returns a single ChatMember) to get the admin status of a single user.
An efficient method to solve this problem is described here: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets#cached-telegram-group-administrator-check
No. You need to hardcode user id in your source and compare if user id in admin-ids array.

Telegram check if user is admin

I am using the telegram bot api to make a bot. I have some commands that can only be sent from admins. Like kick and ban commands. How do I check if the sender is an admin or not? I am using the python-telegram-bot api. I do not want everyone to be able to ban members.
You can use getChatMember method. See following instance:
I have found after searching a bit. The admin status is stored under Telegram.ChatMember.status. It is documented here. It is used by bot.get_chat_member(chat_id, user_id). And then getting status in it.
The other answers are correct, but require an additional call to the API. An efficient solution is to cache the list of admins.
A good solution for this is described here, copied below:
Cached Telegram group administrator check
If you want to limit certain bot functions to group administrators, you have to test if a user is an administrator in the group in question. This however requires an extra API request, which is why it can make sense to cache this information for a certain time, especially if your bot is very busy.
This snippet requires this timeout-based cache decorator. (gist mirror)
Save the decorator to a new file named mwt.py and add this line to your imports:
from mwt import MWT
Then, add the following decorated function to your script. You can change the timeout as required.
#MWT(timeout=60*60)
def get_admin_ids(bot, chat_id):
"""Returns a list of admin IDs for a given chat. Results are cached for 1 hour."""
return [admin.user.id for admin in bot.get_chat_administrators(chat_id)]
You can then use the function like this:
if update.message.from_user.id in get_admin_ids(bot, update.message.chat_id):
# admin only
Note: Private chats and groups with all_members_are_administrator flag, are not covered by this snippet. Make sure you handle them.

wso2 5.3.0 authenticate using one secondary user store and authorize using another

I'm new to wso2 and there are many new concepts to me ... I'm looking for a yes/no answer to the following question:
With wso2is, is it possible to authenticate users using one secondary user store (AD / LDAP) and authorize them using another secondary user store (JDBC, a database with only user and role tables)?
If the answer to the question is "yes", can you please provide me some links to some related examples or documents?
Any suggestions?
Thanks.
Yes, its possible. we can use different user stores.
Please refer
https://docs.wso2.com/display/IS530/Architecture
https://docs.wso2.com/display/IS530/Configuring+Single+Sign-On
Yes!! it is possible. Write your own custom UserStore and overwrite the method getting claims from user store.
Google it and you will find steps to do that.