For audit purposes I'm trying to revoke/remove all blocked users from groups using a Python script. Until now I managed just to list all blocked users in my Gitlab instance using a simple curl:
curl -H "Private-Token: xxx” https://mygitlab.domain.com/api/v3/users?blocked=true. Can anyone point me to the right direction for a list with the groups, blocked users\group and how to revoke them using Gitlab API and Python. Any suggestion would be appreciated.
Thanks
I will give you a path to follow what you want, because stackoverflow is not a scripting service.
I don't how you are comfortable with scripting
Some tips to follow
List all groups
For each group, list all users
List all blocked users
Remove/Revoke every user of each group
This is the basic of your script, in this order
The next step is related the language that you want to use, in this case, python
I don't know if you know how to make http requests with python and, if not, read this article
https://rapidapi.com/blog/how-to-use-an-api-with-python/
This kind of audit is part of a larger effort followed by Epic 3155: "Provide an audit report of user permissions by group and project"
This is being implemented with, as a first step, GitLab 13.12 (May 2021)
Added total group and project count to admin users table
Previously, it was difficult to know how many groups and projects a user belonged to. Compliance-minded organizations, in particular, want to know which users have access to what systems or resources as part of their access management policy.
This information provides visibility into your users’ memberships to know if a user has too much access, may have leftover access from a change in their role or employment, or help you determine the scope of a user’s involvement in your company’s projects.
Now it’s easier to get a high-level view of your users’ memberships for auditing purposes.
In this iteration towards an exportable user access report we’ve added additional data to the admin panel for self-managed instances to show the total number of groups and projects a user belongs to.
See Documentation and Epic.
And:
See GitLab 13.12 (May 2021)
Users' group counts now displayed in Admin Area
The user list in the Admin Area now shows the total number of groups
a given user has access to. The group count is a sum of both group and subgroup membership.
This is incredibly valuable,
because you can easily see how much access users have and quickly
identify when action is needed.
For example, you might use this information
to ensure that deactivated accounts no longer have access to any projects or
groups in GitLab.
See Documentation and Epic.
Related
I want to create a project in Python, Django. So I will be the admin. I will allow employer to create their system that allows their employee to login. How would I do so? I cant find any documentation on it. Employer will have to create employee account.
I'm assuming that you're already somewhat familiar with Django, and know how to set the system up so that you can create users in the admin page as a superuser. If this is not the case, you would benefit from working through a couple of tutorials on YouTube or one of the courses on Udemy.
A couple of options you have, based on what I think you're trying to do:
You grant the employer staff/admin permissions and allow them to access the Django Admin page so that they can create additional users at will. This would be the easiest way, but could also be the most risky if they do not know what they're doing.
Create custom permissions groups: documentation. If you don't want individual users to create their own accounts, you would need to set up views to allow those with the proper permissions to do it on their behalf.
There are several other options, but a lot of it is going to depend on how/where you plan to deploy your system and how complex you want the whole thing to be. Depending on the content, you might to look into DjangoCMS, which could offer you everything you're looking for out of the box.
If you can be a bit more specific about A) how you plan to deploy, B) what type of content the site will serve, C) where you plan to deploy it, and D) how Django-savvy the employer will be, it would be easier to provide you with a more comprehensive answer.
My team are developing a payment system for our web services. The site is built using Django, with the payment services provided by stripe. We are using dj-stripe to integrate the two.
For development we are using the stripe test environment, but we are doing this on multiple development servers, each with it's own dev DB.
dj-stripe identifies which customer to associate payment, card and source activity with using the dj-stripe customer id. This causes a conflict in the information for customers with the same ids on different development severs.
We have thought of a number of workarounds for this, the top two choices are;
1) Generate an offset in the customer ids to prevent clash. The issue is this may break down as time goes on, with more developers joining. It fixes the issue for now, but doesn't guarantee it won't be an issue again.
2) Create a stripe account for each developer to ensure no clashes and only use the test environment. However, this seems like something stripe wouldn't be happy with if we end up with many devs working on the project.
I am interested in whether there is a standard solution or best practices for this issue.
In case anyone comes here for a similar issue, Stripe responded very quickly to our question on this. They already have a feature to deal with this, it just wasn't immediately obvious to us.
Stripe have a feature for you to add multiple accounts from your dashboard. You can simple create an account for each developer and just use the test keys for that account. Then invite all developers in your team to have read access to the account so that everyone can see the logs.
I have found lots of information on the internet about adding Members to a Group in Googlegroups, but I cant manage to get any of it to work.
I am working in Python-DJango.
Using a bussiness account, I manage to add them using Provisioning API, but I could not do it with the new Directory API.
The problem is the group I want to add people to is not a business one, it's an ordinary googlegroups one:
group_name#googlegroups.com
From what I have found, and what I did for the business group I have the following code:
groupClient = gdata.apps.groups.client.GroupsProvisioningClient(domain=domain)
groupClient.ClientLogin(email="user#gmail.com", password="xxx", source='apps')
groupClient.AddMemberToGroup("group_name#googlegroups.com", "newUser#gmail.com")
I wanted to know what I have to put in the domain field. With the business account it was the business domain, but being a normal googlegroups one I am not sure. I have tried googlegroups.com and doesn't work, as I always get a invalid domain error.
Any help would be appreciated
Thanks!
The Provisioning API (deprecated) and the new Admin SDK are both designed to work with Google Apps for Business and EDU and only work against Google Groups for Business (groups with a custom #yourdomain.com address).
You cannot use these APIs with consumer Google Groups that have #googlegroups.com email addresses. For these groups, your only option is to manage membership via the web interface.
Can you advice me with some articles/applications that allows you create SaaS(Software as a Service) application with Python and Django.
For the moment the general topics I do not understand are:
Do you have one working application for all clients or one app per client
How do you manage database access, permissions or different DB for each client
Are there any tools that allows you to convert one app to SaaS
one project, this will make maintenance easier. I handle host resolution with middleware in django-ikari.
you don't. see #1
I use the following :
django-ikari : anchored (sub)domains
django-guardian : per object permissions
django-tastypie : easy RESTful api
django-userprofiles : better than django-registration
django-billing : plan based subscription controls
django-pricing : plan based subscription definition
While not necessary, the following will help in the long run:
django-hunger : private beta signups
django-waffle : feature flip
django-classy-tags : nice, easy and neat templatetag creation
django-merchant : abstracted payment gateway framework
django-mockups : fast testing with models
django-merlin : better multi-step forms (wizards)
Finally, nice to have
django-activity-stream
A very basic, elementary example of how you would go about it.
Suppose you have a simple app designed to solve a particular business case. For example, you created an app to handle room reservations at your office.
To "convert" this app into a service you have to configure it such that most of the user-specific parts of the application are parametric (they can be "templatized" - for lack of better word).
This is how the front end would be converted. You might create variables to hold the logo, headline, teaser, color scheme for the app; allowing each user to customize their instance.
So far, your app is able to customize itself on the front end. It is still using the same database that was designed in phase one.
Now comes the matter of showing only those fields that are relevant to a particular user. This would be parameterizing the database. So you might add a column that identifies each row as belonging to a particular user; then create views or stored procedures that filter records based on the logged in user.
Now the application is able to be "rented" out; since you are able to customize the instance based on the user.
It then just gets bigger from here - depending on the scale, type and intended customization of your application. You might decide that your application performs better when each user has their own dedicated database instead of the stored procedure + view combo.
You may decide that for some user types (or "packages"), you need a dedicated instance of your application running. So for "premium" or "ultra" users you want to have their own dedicated system running.
If your application requires lots of storage - you might decide to charge separately for storage.
The bottom line is it has nothing to do with the language used. Its more an architecture and design problem.
Software as a Service is just a marketing word, it's technically no different from a server that is accessible over the internet. So question 3 makes no sense. That leaves us with question 1 and 2:
What do you mean with 'app' in this context? Your web application (built with Python and Django) can have multiple Django apps (components that make up the web application) but I think that's not what you mean. You can build your website in Python/Django and have various customization options depending on which user (client) is logged in. For example, a premium client can have several advanced options enabled but it's still part of the same codebase. It's just that some options (buttons/controls, etc) are not shown for certain clients
Django has plenty of tools for user management, permissions and groups. You can give each user (each client) different permissions and these permissions determine what they can do. Database access should be managed by your web application. For example, the code determines what information needs to be displayed on the webpage (depending on which client is logged in) and that code retrieves the information from the database. Depending on the scale that you're aiming for, you can also specify which database should be used to retrieve the information from.
I have a blog post describing my proposal of how to go about making a multi tenant SAAS web application using Django. Multi-tenancy here means that when user registers, they have their sub-domain. To recap:
All tenants share one database, but each has their own schemas. Imagine you have website abc.com and someone registered a xyz tenant so that they access their page through xyz.abc.com, then for a tenant xyz you have a separate schema containing all the tables thus encapsulating data related only to xyz tenant. There are other ways, like having one database and one schema for all, or having even separate databases. But schemas approach is the best trade-off. The django-tenants library's documentation contains more detailed info if you are interested
Use django-tenants library to abstract away work with tenants. When someone accesses xyz.abc.com, you need to know that xyz is the tenant and that you should use xyz schema. django-tenants library does this for you so on each request you can obtain the tenant object by simply doing current_tenant = request.tenant
You need to differentiate between shared tables and tenant-specific tables. For example, having table with list of orders is tenant-specific. Every tenant might have their own database containing all their orders. This table should be inside xyz schema. At the same time, you will have some core Django tables, like user. The data can be shared, for example, to disallow two users registering with the same email.
You need to configure your DNS to catch a wildcard expression *.abc.com, for which you can add an A record inside your CPanel with *.abc.com linking to the IP of your server
I have developed a small django web application. It still runs in the django development web server.
It has been decided that if more than 'n' number of users like the application, it will be approved.
I want to find out all the users who view my application.
How can find the user who views my application?
Since I was the user who ran the application, all python ways of getting the username returns my name only.
Please help.
You can look in the admin to see how many usernames are there, assuming everyone who likes it creates one. Or you can look at your server logs and count the unique IPs.
You can keep track of your visitors by adding a call to google analytics in your web pages. Or, if you do not wish to use a Google product, there are plenty of other analytics packages to keep track of visitors locally.
These packages tell you a lot more than just the number of unique visitors.
An open source alternative can be found at http://piwik.org/ . Also, see http://forge.2metz.fr/p/python-piwik/
Step 1. Add a model -- connected users. Include an FK to username and a datetime stamp.
Step 2. Write a function to log each user's activity.
Step 3. Write your own version of login that will call the Django built-in login and also call your function to log each user's activity.
Step 4. Write a small application -- outside Django -- that uses the ORM to query the connected users table and write summaries and counts and what-not.
You have a database. Use it.