-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add etcd basic auth support #951
Changes from 14 commits
dea6510
dc781df
b9a493c
a6429c6
e31164b
19f463d
c6c6297
c029e0d
3274519
9ae2397
8054f30
21248fe
780abdf
4f94e84
d550545
4c3bc5c
6dc2fad
40197e7
ea72f57
f40b7f7
ceb09ea
2528a86
df01aaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,48 @@ if [[ `grep -c "INFO" ./error.log` -eq '0' ]]; then | |
echo "failed: failed to write log on right level" | ||
exit 1 | ||
fi | ||
|
||
|
||
# etcd basic auth | ||
# add root user | ||
curl -L http://localhost:2379/v3/auth/user/add \ | ||
-X POST -d '{"name": "root", "password": "apisix-dashboard"}' | ||
juzhiyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# add root role | ||
curl -L http://localhost:2379/v3/auth/role/add \ | ||
-X POST -d '{"name": "root"}' | ||
|
||
# grant root role to root user | ||
curl -L http://localhost:2379/v3/auth/user/grant \ | ||
-X POST -d '{"user": "root", "role": "root"}' | ||
|
||
# enable auth | ||
curl -L http://localhost:2379/v3/auth/enable -X POST -d '{}' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could try to run |
||
./manager-api & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about |
||
sleep 3 | ||
pkill -f manager-api | ||
|
||
# make sure it's wrong | ||
if [[ `grep -c "etcdserver: user name is empty" ./error.log` -eq '0' ]]; then | ||
echo "failed: failed to validate etcd basic auth" | ||
exit 1 | ||
fi | ||
|
||
# modify etcd auth config | ||
sed -i '1,$s/# username: "root" # ignore this argument if not enable auth/username: "root"/g' conf/conf.yaml | ||
sed -i '1,$s/# password: "123456" # ignore this argument if not enable auth/password: "apisix-dashboard"/g' conf/conf.yaml | ||
|
||
./manager-api & | ||
|
||
# validate process is right by requesting login api | ||
resp=$(curl http://127.0.0.1:9000/apisix/admin/user/login -X POST -d '{"username":"admin", "password": "admin"}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This API does not access store, we would better add a case to access store such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this api does't access store. but it's enough for verifing this test, if not this process has been killed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if do other things like create a consumer, clear dirty is necessary, making easy thing gets complex. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the discussion here is based on our goals:
I have not encountered a situation where the manager-api alive but cannot access the ETCD normally, so I think it is acceptable to just verify the process survival (although the latter would be better) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ye, you are right, i have done it. |
||
token=$(echo "${resp}" | sed 's/{/\n/g' | sed 's/,/\n/g' | grep "token" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g' | sed 's/"//g') | ||
if [ -z "${token}" ]; then | ||
echo "login failed" | ||
fi | ||
|
||
sleep 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could try some curl here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's right, i have a lazy just now. |
||
pkill -f manager-api | ||
|
||
check_logfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be under the standard library.