如何让 Jenkins 凭证变量(即“mysqlpassword”)可供 Jenkins 声明性管道的所有阶段访问?
下面的代码片段工作正常并打印我的凭据。
node {
stage('Getting Database Credentials') {
withCredentials([usernamePassword(credentialsId: 'mysql_creds', passwordVariable: 'mysqlpassword', usernameVariable: 'mysqlusername')])
{
creds = "\nUsername: ${mysqlusername}\nPassword: ${mysqlpassword}\n"
}
println creds
}
}
Run Code Online (Sandbox Code Playgroud)
如何将上述代码合并到当前的管道中,以便管道脚本的所有阶段(即全局)都可以访问 mysqlusername 和 mysqlpassword 变量。
我的管道脚本布局如下所示:
pipeline { //indicate the job is written in Declarative Pipeline
agent { label 'Prod_Slave' }
environment {
STAGE_2_EXECUTED = "0"
}
stages {
stage ("First Stage") {
steps {
echo "First called in pipeline"
script {
echo "Inside script of First stage"
}
}
} …Run Code Online (Sandbox Code Playgroud) 我想使用我的服务器上的现成凭证。
我愿意EDITOR="nano --wait" bin/rails credentials:edit
然后,我将 credential.yml.enc 和 master.key 的内容替换为服务器上这些文件中的内容。但是当我尝试读取凭据时出现错误Couldn't decrypt config/credentials.yml.enc. Perhaps you passed the wrong key?
我正在尝试编写 python 代码,它将使用 LDAP 模块来验证 LDAP 连接:
import configuration
from ldap3 import Server, Connection, SIMPLE, SYNC, ALL
server = Server(configuration.LDAP_SERVER, port=XXXX, get_info=ALL)
c = Connection(server, authentication=SIMPLE, user=configuration.LDAP_USER, password=configuration.LDAP_PASS, check_names=True, lazy=False, client_strategy=SYNC, raise_exceptions=False)
c.open()
c.bind()
Run Code Online (Sandbox Code Playgroud)
运行代码时,我得到:
{'result': 49, 'description': 'invalidCredentials', 'dn': '', 'message': '80090308: LdapErr: DSID-0C09042A, comment: AcceptSecurityContext error, data 52e, v3839\x00', 'referrals': None, 'saslCreds': None, 'type': 'bindResponse'}
Run Code Online (Sandbox Code Playgroud)
我确信我使用的用户名和密码是正确的。你能告诉我代码有什么问题吗?
我已为生产 RDS 实例创建了只读副本,但我不知道在哪里可以看到该副本的登录凭据。
当我进入秘密管理屏幕并尝试创建新秘密时,副本实例不存在。
而且我不知道密码(通常在控制台创建数据库后会显示密码)。
我如何获得以下信息?用户名、密码、数据库名
credentials amazon-web-services amazon-rds read-replication aws-secrets-manager
我正在尝试实施以下 AWS 文章中介绍的解决方案:
所以我做了接下来的步骤:
创建本地密钥库:
keystore winpty openssl pkcs12 -export -in eeb81a0eb6-certificate.pem.crt -inkey eeb81a0eb6-private.pem.key -name myname -out my.p12 -password pass:mypass
keytool -importkeystore -destkeystore mykeystore.jks -srckeystore my.p12 -srcstoretype PKCS12 -deststorepass mypass -srcstorepass mypass
创建本地信任库:
keytool -keystore my_ca.jks -alias myalias -import -file AmazonRootCA1.pem
我的代码:
public class AWSSessionCredentialsProviderImpl implements AWSSessionCredentialsProvider {
private static final Logger LOGGER = LogManager.getLogger(AWSSessionCredentialsProviderImpl.class.getName());
private final Gson gson = new Gson();
private SdkHttpClient client;
private HttpExecuteRequest request;
private String awsAccessKeyId;
private String awsSecretAccessKeyId; …Run Code Online (Sandbox Code Playgroud) 如何使用管理控制台 API 在 keycloak 中导出具有凭据的用户
我使用了此端点,但它不包含用户的凭据
curl -X GET https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/users
{
"id": "dbede89b-dbf8-4b4b-84a6-da7b6c1877e3",
"createdTimestamp": 1607591201217,
"username": "admin",
"enabled": true,
"totp": false,
"emailVerified": false,
"disableableCredentialTypes": [],
"requiredActions": [],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
}
},
Run Code Online (Sandbox Code Playgroud)
如何恢复具有凭据的用户?
以下代码工作正常:
request({
url: 'https://xxxxxxx/oauth/token',
method: 'POST',
auth: {
user: 'clientId',
pass: 'clientSecret'
},
form: {
'grant_type': 'client_credentials'
}
}, function(err, res) {
var json = JSON.parse(res.body);
console.log("Access Token:", json.access_token);
});
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用 Axios 复制此内容(因为请求现已弃用)时,我不断收到 401
axios.request({
url: 'https://xxxxxxx/oauth/token',
method: 'POST',
auth: {
username: 'clientId',
password: 'clientSecret',
},
headers: {
Accept: 'application/json','Content-Type':'application/x-www-form-urlencoded',
},
data: {
grant_type: 'client_credentials',
},
}).then(function(res) {
console.log(res);
}).catch(function(err) {
console.log("error = " + err);
});
Run Code Online (Sandbox Code Playgroud)
ie catch 获取错误响应 401
关于如何将成功的“请求”编码到 axios 中的任何想法?
尝试使用 Ansible 从 Linux Zorin 控制主机连接到 Windows 主机。在 Windows 机器中安装 winrm 并将所有必需的身份验证方法设置为 True。
Window Host 中 winrm 的配置
PS C:\WINDOWS\system32> winrm get winrm/config
Config
MaxEnvelopeSizekb = 500
MaxTimeoutms = 60000
MaxBatchItems = 32000
MaxProviderRequests = 4294967295
Client
NetworkDelayms = 5000
URLPrefix = wsman
AllowUnencrypted = true
Auth
Basic = true
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = false
DefaultPorts
HTTP = 5985
HTTPS = 5986
TrustedHosts
Service
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GXGR;;;S-1-5-21-2039588290-1060779563-2652726705-1011)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
MaxConcurrentOperations = 4294967295 …Run Code Online (Sandbox Code Playgroud) 我对CORS服务器进行AJAX调用,我尝试使用javascript客户端读取响应时返回的cookie,但是徒劳无功.
response.header('Access-Control-Allow-Origin', '*');
response.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, Set-Cookie');
response.header('Access-Control-Expose-Headers', "Set-Cookie");
//------SET COOKIES
response.cookie('SessionId', GeneratorId(64), {
maxAge:3600000,
httpOnly:flase // i disable httpOnly ==> does not work
});
Run Code Online (Sandbox Code Playgroud)
var xhttp=new XMLHttpRequest();
xhttp.open("POST", "http://localhost:9090/api/map", true);
xhttp,send(`{layer:1}`);
Run Code Online (Sandbox Code Playgroud)
//Append another response' header
response.header('Access-Control-Allow-Credentials','true');
Run Code Online (Sandbox Code Playgroud)
// Before xhttp.send , I add another instruction :
xhttp.withCredentials=true;
Run Code Online (Sandbox Code Playgroud)
//Avoid the wildcard on Access-Control-Allow-Origin =>Replace the first header by :
response.header('Access-Control-Allow-Origin', request.get('Origin'));
Run Code Online (Sandbox Code Playgroud)
credentials ×10
java ×2
amazon-rds ×1
ansible ×1
aws-cli ×1
axios ×1
client ×1
cookies ×1
cors ×1
docker ×1
dockerfile ×1
httpresponse ×1
javascript ×1
jenkins ×1
json ×1
keycloak ×1
keystore ×1
ldap3 ×1
node.js ×1
oauth-2.0 ×1
python-3.6 ×1
spring-boot ×1
truststore ×1
winrm ×1