技术博客——通过gitlab api批量注册用户

gitlab登录界面本身提供了register功能,但需要手工一个个添加,对于一次性会添加整个班级的学生的软工平台来说并不科学合理。使用gitlab api来批量注册用户是一个比较好的选择。

gitlab api的官方文档中的user栏给出了create user的方法

User creation

Creates a new user. Note only administrators can create new users. Either password, reset_password, or force_random_password must be specified. If reset_password and force_random_password are both false, then password is required.

Note that force_random_password and reset_password take priority over password. In addition, reset_password and force_random_password can be used together.

POST /users

Parameters:

Attribute Required Description
admin No User is admin - true or false (default)
avatar No Image file for user’s avatar
bio No User’s biography
can_create_group No User can create groups - true or false
color_scheme_id No User’s color scheme for the file viewer (see the user preference docs for more information)
email Yes Email
extern_uid No External UID
external No Flags the user as external - true or false (default)
extra_shared_runners_minutes_limit No Extra pipeline minutes quota for this user
force_random_password No Set user password to a random value - true or false (default)
group_id_for_saml No ID of group where SAML has been configured
linkedin No LinkedIn
location No User’s location
name Yes Name
organization No Organization name
password No Password
private_profile No User’s profile is private - true, false (default), or null (will be converted to false)
projects_limit No Number of projects user can create
provider No External provider name
public_email No The public email of the user
reset_password No Send user password reset link - true or false(default)
shared_runners_minutes_limit No Pipeline minutes quota for this user
skip_confirmation No Skip confirmation - true or false (default)
skype No Skype ID
theme_id No The GitLab theme for the user (see the user preference docs for more information)
twitter No Twitter account
username Yes Username
website_url No Website URL

需要的信息有,用户的密码,用户名,邮箱,别名

需要注意的是,使用gitlab api创建的用户无法直接登陆,需要进行邮箱验证且修改密码,在csnd等寻找无果

但仔细阅读gitlab api的文档,发现其中有skip_confirmation字段,创建时将此字段置为true即可跳过邮箱验证正常登录。

同理,将reset_password置为false即可以去除登陆时修改密码的提示

在实现时,为了避免创建重复的用户或账号、密码格式不对等导致gitlab报错引起服务器报错,所以还需要调用gitlab api提供的List users方法,查找所有的用户信息,并与本地数据库存储的数据进行比对,来防止创建相同的用户。关于邮箱、密码等的格式,参考gitlab对于账号、密码邮箱等的规范,在vue的form组件中采用正则匹配的方法进行校对,就可以保证符合规范的操作不会使得界面崩溃。

但若不通过平台进行操作,直接在gitlab上进行注册的用户,由于本地数据库没有其信息,可能会导致意料之外的问题,,不仅包括用户的问题,还有项目等其他方面。故需要限制用户对于gitlab的随意操作,之后可能会在gitlab root用户的admin中对gitlab进行进一步的设置以限定用户行为。

[技术博客]大闸蟹的技术博客,通过gitlab api进行用户批量创建的更多相关文章

  1. 这是一个专注于电脑技术、软件应用、互联网、嵌入式,电子技术行业等的原创IT博客

    http://www.choovin.com/ 这是一个专注于电脑技术.软件应用.互联网.嵌入式,电子技术行业等的原创IT博客

  2. 继网易博客后搜狐博客也增加了nofollow标签

    继网易博客后搜狐博客也增加了nofollow标签 今天在搜狐博客发表了篇文章,在末端添加上我的版权,结果回头查看是发现,这个锚文本被加上了nofollow标签,也就是说这样的外链已经没有传递权重的作用 ...

  3. 【博客导航】Nico博客导航汇总

    摘要 介绍本博客关注的内容大类.任务.工具方法及链接,提供Nico博文导航. 导航汇总 [博客导航]Nico博客导航汇总 [导航]信息检索导航 [导航]Python相关 [导航]读书导航 [导航]FP ...

  4. MWeb 1.3.7 发布!增加发布到 Wordpress 等支持 MetaWeblog API 的服务,如:Wordpress 博客、新浪博客、cnblogs、oschina。

    MWeb 1.3.7 版的新功能 增加发布到 Wordpress 等支持 Metaweblog API 的服务,目前经测试过的有: Wordpress 博客.新浪博客.cnblogs.oschina. ...

  5. asp.net批量发布博客到各大博客平台

    新浪博客 http://upload.move.blog.sina.com.cn/blog_rebuild/blog/xmlrpc.php 网易博客 http://os.blog.163.com/ap ...

  6. 基于Laravel开发博客应用系列 —— 构建博客后台管理系统

    一个完整的博客应用不能没有后台管理系统.所以在本节中我们将继续完善博客应用 —— 开发后台管理系统. 1.创建路由 在上一节十分钟创建博客项目中,已经设置过了 app/Http/routes.php, ...

  7. Node.js 从零开发 web server博客项目[express重构博客项目]

    web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...

  8. Node.js 从零开发 web server博客项目[koa2重构博客项目]

    web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...

  9. java基础-网络编程(Socket)技术选型入门之NIO技术

    java基础-网络编程(Socket)技术选型入门之NIO技术 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.传统的网络编程 1>.编写socket通信的MyServer ...

随机推荐

  1. tornado2.2安装教程

    最近要用到vxworks 系统,所以避免不了要安装tornado 软件,进行相关的开发. 自己在安装过程中遇到了点点问题,这里记录下来,免得以后再次安装时遇到同样的问题. 1.   首先提供一个tor ...

  2. Abp Vnext3 vue-admin-template(一用户登录)

    Git地址https://github.com/PanJiaChen/vue-admin-template/blob/master/README-zh.md 官方文档https://panjiache ...

  3. vue.js框架图片上传组件

    html: <div id="app"> <div class="hello"> <div class="upload& ...

  4. MySQL高级语句(二)

    目录: 1.别名 2.子查询 3.EXISTS 4.连接查询 5.CREATE VIEW 视图 6.UNION 联集 7.交集值 8.无交集值 9.CASE 10.算排名 11.算中位数 12.算累积 ...

  5. (2)java Spring Cloud+Spring boot+mybatis企业快速开发架构之SpringCloud-Spring Cloud是什么?Spring Cloud版本介绍

    ​ Spring Cloud 是一系列框架的有序集合.它利用 Spring Boot 的开发便利性,巧妙地简化了分布式系统基础设施的开发,如服务注册.服务发现.配置中心.消息总线.负载均衡.断路器.数 ...

  6. 洛谷P1309——瑞士轮(归并排序)

    https://www.luogu.org/problem/show?pid=1309#sub 题目背景 在双人对决的竞技性比赛,如乒乓球.羽毛球.国际象棋中,最常见的赛制是淘汰赛和循环赛.前者的特点 ...

  7. C++ 飞行游戏

    源代码: #include<bits/stdc++.h> #include<windows.h> #include<conio.h> using namespace ...

  8. Nginx系列(6)- nginx: [error] CreateFile() "D:\nginx-1.20.1/logs/nginx.pid" failed (2: The system cannot find the file specified)

    背景 修改nginx配置文件nginx.conf后,想要重启nginx使配置生效.cmd进入nginx安装目录,输入命令: nginx -s reload 报错:nginx: [error] Crea ...

  9. Django边学边记—模板

    功能 产生html,且不仅仅是一个html 包含: 静态内容:html,css,js 动态内容:模板语言 使用 一般使用 Django中提供的简写函数render调用模板 render(request ...

  10. 『GoLang』fmt包的使用

    目录 1. fmt 包初识 2. 格式化 verb 应用 2.1 通用 2.2 布尔值 2.3 整数 2.4 浮点数与复数 2.5 字符串和 []byte 2.6 指针 2.7 其他 flag 2.8 ...