mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-05-31 19:09:53 +08:00
[新增功能](master): 新增对gitlab通过令牌推送的支持
新增对Gitlab提供的通过Oauth2协议认证,操作Git的支持
This commit is contained in:
@@ -52,7 +52,7 @@ public class GitRepo {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ssh秘钥或者账号密码
|
||||
* 设置ssh秘钥或者账号密码或者使用OAuth2进行认证
|
||||
*
|
||||
* @param transportCommand
|
||||
* @return
|
||||
@@ -87,6 +87,13 @@ public class GitRepo {
|
||||
transportCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
|
||||
properties.getUsername(),
|
||||
properties.getPassword()));
|
||||
} else if (StringUtils.isNotBlank(properties.getUrl()) && properties.getUrl().contains("oauth2:")) {
|
||||
//采取OAuth2进行认证 面向gitlab api场景 Heaven96 @ 2022年11月30日13:27:38 开始
|
||||
final String url = properties.getUrl();
|
||||
int start = url.indexOf("oauth2:") + 7;
|
||||
int end = url.indexOf("@");
|
||||
transportCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider("oauth2",url.substring(start,end)));
|
||||
//采取OAuth2进行认证 面向gitlab api场景 Heaven96 @ 2022年11月30日13:27:38 结束
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user