我正在尝试编写一个自定义Concourse资源(用Python编写),该资源访问Con居尔实例的REST以获取信息。我无法在登录时获得无记名代金券。问题是,当我遵循这个shell脚本的要点时
#!/bin/bash
## Variables required #need to update these to take inputs for getting token per team and target.
CONCOURSE_URL="http://localhost:8080"
CONCOURSE_USER="test"
CONCOURSE_PASSWORD="test"
CONCOURSE_TEAM="test"
CONCOURSE_TARGET="my-concourse"
function get_token() {
## Create a file named token that will be used to read and write tokens
touch token
## extract the LDAP authentication url and write to token file
LOCAL_AUTH_URL=$CONCOURSE_URL$(curl -b token -c token -L "$CONCOURSE_URL/sky/login" -s | grep "/sky/issuer/auth/local" | awk -F'"' '{print $4}')
echo "url is $LOCAL_AUTH_URL"
# login using username and password while writing to the token file
curl -s -o /dev/null -b token -c token -L --data-urlencode "login=$CONCOURSE_USER" --data-urlencode "password=$CONCOURSE_PASSWORD" "$LOCAL_AUTH_URL"
ATC_BEARER_TOKEN=`grep 'Bearer' token | cut -d\ -f2 | sed 's/"$//'`
echo $ATC_BEARER_TOKEN
}涉及到许多重定向,其中至少有一些将container实例称为在http://localhost:8080,它不能从资源的坞容器中工作。
因此,我希望参数化外部基url,并在资源配置中显式地给出它。手动处理重定向并将本地IP重写到URL在最后一步使用代码400“批准”时失败,可能是因为它看起来像是某种跨域攻击。
环境变量ATC_EXTERNAL_URL始终是localhost:8080,我怀疑这也是在形成重定向urls时使用的。这能放在什么地方吗?
我对golang不在行,但在我看来,https://github.com/concourse/concourse-pipeline-resource调用fly二进制文件是为了实现资源内部的某种登录。不能说我能得到它能做什么和怎么做。
所有的帮助都很感激..。
发布于 2020-05-22 14:58:00
env $ATC_EXTERNAL_URL最有可能对应于在启动Concourse时指定的外部url,所以是的,它可以被更改(如果您使用的是像Github或OAuth这样的外部auth )。您正确地假设它用于构造回调URL。
而且,我不想成为那样的Guy(TM),但是Concourse不是公开的,随时都可能更改。您想要做哪些您无法从fly CLI获得的操作?您的资源可以在需要时调用ATC_EXTERNAL_URL来获取动态CLI,然后以这种方式执行命令。
https://stackoverflow.com/questions/61910319
复制相似问题