-
Notifications
You must be signed in to change notification settings - Fork 167
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
Add groups #559
Merged
+815
−22
Merged
Add groups #559
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9ea4818
add od_group and reading
NikitaUnisikhin 4d354c8
add group_query and reading
NikitaUnisikhin 4b00167
rewrite group and reading, now group is rules field
NikitaUnisikhin ad28170
its work
NikitaUnisikhin 0dfc9ab
add tests
NikitaUnisikhin fd0ebed
refactoring
NikitaUnisikhin 6decd93
fix sigfault
NikitaUnisikhin 9d42e4e
add new tests, all tests pass
NikitaUnisikhin 375d302
refactoring
NikitaUnisikhin 716551e
fix fmt
NikitaUnisikhin f9160fe
fixes
NikitaUnisikhin 79f6dc0
Merge branch 'master' into add_groups
NikitaUnisikhin 1680276
Merge branch 'master' into add_groups
NikitaUnisikhin 3800860
fix compatibility address_range and group
NikitaUnisikhin 40cbb0f
Cchanged the logic. now it is based on obtaining a list of group memb…
NikitaUnisikhin 8d1f634
apply_fmt
NikitaUnisikhin 07458cd
Small fix
x4m a6e7169
Some more fixes
x4m b4fa74b
Fmt again
x4m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ listen { | |
compression yes | ||
} | ||
|
||
|
||
storage "postgres_server" { | ||
type "remote" | ||
host "localhost" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
listen { | ||
host "*" | ||
port 6432 | ||
} | ||
|
||
storage "postgres_server" { | ||
type "remote" | ||
|
||
host "localhost" | ||
port 5432 | ||
} | ||
|
||
database "group_db" { | ||
user "group_user1" { | ||
authentication "none" | ||
storage "postgres_server" | ||
pool "session" | ||
} | ||
|
||
group "group1" { | ||
authentication "md5" | ||
password "password1" | ||
|
||
storage "postgres_server" | ||
storage_db "postgres" | ||
storage_user "postgres" | ||
|
||
pool_routing "internal" | ||
pool "session" | ||
group_query "select pg_has_role('%s', 'group1', 'MEMBER')" | ||
} | ||
|
||
user "group_user2" { | ||
authentication "none" | ||
storage "postgres_server" | ||
pool "session" | ||
} | ||
|
||
user "group_user3" { | ||
authentication "none" | ||
storage "postgres_server" | ||
pool "session" | ||
} | ||
|
||
group "group2" { | ||
authentication "md5" | ||
password "password2" | ||
|
||
storage "postgres_server" | ||
storage_db "postgres" | ||
storage_user "postgres" | ||
|
||
pool_routing "internal" | ||
pool "session" | ||
group_query "select pg_has_role('%s', 'group2', 'MEMBER')" | ||
} | ||
|
||
user "group_user4" { | ||
authentication "none" | ||
storage "postgres_server" | ||
pool "session" | ||
} | ||
|
||
user "group_user5" { | ||
authentication "none" | ||
storage "postgres_server" | ||
pool "session" | ||
} | ||
} | ||
|
||
database default { | ||
user default { | ||
authentication "none" | ||
|
||
storage "postgres_server" | ||
pool "session" | ||
pool_size 0 | ||
|
||
pool_timeout 0 | ||
|
||
pool_ttl 1201 | ||
|
||
pool_discard no | ||
|
||
pool_cancel yes | ||
|
||
pool_rollback yes | ||
# seconds | ||
pool_client_idle_timeout 20 | ||
# seconds | ||
pool_idle_in_transaction_timeout 20 | ||
|
||
client_fwd_error yes | ||
application_name_add_host yes | ||
server_lifetime 1901 | ||
log_debug no | ||
|
||
quantiles "0.99,0.95,0.5" | ||
client_max 107 | ||
} | ||
} | ||
|
||
unix_socket_dir "/tmp" | ||
unix_socket_mode "0644" | ||
|
||
log_file "/var/log/odyssey.log" | ||
log_format "%p %t %l [%i %s] (%c) %m\n" | ||
log_debug no | ||
log_config yes | ||
log_session no | ||
log_query no | ||
log_stats yes | ||
daemonize yes | ||
|
||
locks_dir "/tmp/odyssey" | ||
graceful_die_on_errors yes | ||
enable_online_restart yes | ||
bindwith_reuseport yes | ||
|
||
stats_interval 60 | ||
|
||
pid_file "/var/run/odyssey.pid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash -x | ||
|
||
set -ex | ||
|
||
/usr/bin/odyssey /group/config.conf | ||
|
||
users=("group_user1" "group_user2" "group_user3" "group_user4" "group_user5") | ||
for user in "${users[@]}"; do | ||
psql -h localhost -p 6432 -U "$user" -c "SELECT 1" group_db >/dev/null 2>&1 || { | ||
echo "ERROR: failed backend auth with correct user auth" | ||
|
||
cat /var/log/odyssey.log | ||
echo " | ||
|
||
" | ||
cat /var/log/postgresql/postgresql-14-main.log | ||
|
||
exit 1 | ||
} | ||
done | ||
|
||
psql -h localhost -p 6432 -U postgres -c "GRANT group1 TO group_user1;" group_db | ||
sleep 1 | ||
psql -h localhost -p 6432 -U group_user1 -c "SELECT 1" group_db >/dev/null 2>&1 || { | ||
echo "ERROR: group auth apply for over user at config" | ||
|
||
cat /var/log/odyssey.log | ||
echo " | ||
|
||
" | ||
cat /var/log/postgresql/postgresql-14-main.log | ||
|
||
exit 1 | ||
} | ||
|
||
psql -h localhost -p 6432 -U postgres -c "GRANT group1 TO group_user2;" group_db | ||
sleep 1 | ||
psql -h localhost -p 6432 -U group_user2 -c "SELECT 1" group_db >/dev/null 2>&1 && { | ||
echo "ERROR: group auth not apply" | ||
|
||
cat /var/log/odyssey.log | ||
echo " | ||
|
||
" | ||
cat /var/log/postgresql/postgresql-14-main.log | ||
|
||
exit 1 | ||
} | ||
|
||
psql -h localhost -p 6432 -U postgres -c "GRANT group1 TO group_user4;" group_db | ||
psql -h localhost -p 6432 -U postgres -c "GRANT group2 TO group_user4;" group_db | ||
sleep 1 | ||
PGPASSWORD=password1 psql -h localhost -p 6432 -U group_user4 -c "SELECT 1" group_db >/dev/null 2>&1 && { | ||
echo "ERROR: group auth not accepted down group" | ||
|
||
cat /var/log/odyssey.log | ||
echo " | ||
|
||
" | ||
cat /var/log/postgresql/postgresql-14-main.log | ||
|
||
exit 1 | ||
} | ||
PGPASSWORD=password2 psql -h localhost -p 6432 -U group_user4 -c "SELECT 1" group_db >/dev/null 2>&1 || { | ||
echo "ERROR: group auth not apply" | ||
|
||
cat /var/log/odyssey.log | ||
echo " | ||
|
||
" | ||
cat /var/log/postgresql/postgresql-14-main.log | ||
|
||
exit 1 | ||
} | ||
|
||
ody-stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think %s is an injection
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.
Do we need to specify
group_query
at all ?We may just set as default during configuration, using group name for current route.
Is there any alternatives to this one ^^