Commit 53391ff5275168c0779d66f74c938adcb5de4e01
Exists in
6-9-stable-ee
Merge branch '6-9-stable' into 6-9-stable-ee
Showing
8 changed files
with
66 additions
and
17 deletions
Show diff stats
CHANGELOG
... | ... | @@ -9,6 +9,7 @@ |
9 | 9 | - Support changing the 'signin_enabled' option (Konstantinos Paliouras) |
10 | 10 | - Fix Nginx HTTP-to-HTTPS log configuration error (Konstantinos Paliouras) |
11 | 11 | - Create the authorized-keys.lock file for gitlab-shell 1.9.4 |
12 | +- Use sockets and peer authentication for Postgres | |
12 | 13 | |
13 | 14 | 6.9.1 |
14 | 15 | - Fix Nginx HTTP-to-HTTPS log configuration error (Konstantinos Paliouras) | ... | ... |
files/gitlab-cookbooks/gitlab/attributes/default.rb
... | ... | @@ -106,8 +106,8 @@ default['gitlab']['gitlab-rails']['db_encoding'] = "unicode" |
106 | 106 | default['gitlab']['gitlab-rails']['db_database'] = "gitlabhq_production" |
107 | 107 | default['gitlab']['gitlab-rails']['db_pool'] = 10 |
108 | 108 | default['gitlab']['gitlab-rails']['db_username'] = "gitlab" |
109 | -default['gitlab']['gitlab-rails']['db_password'] = "password" | |
110 | -default['gitlab']['gitlab-rails']['db_host'] = "localhost" | |
109 | +default['gitlab']['gitlab-rails']['db_password'] = nil | |
110 | +default['gitlab']['gitlab-rails']['db_host'] = nil | |
111 | 111 | default['gitlab']['gitlab-rails']['db_port'] = 5432 |
112 | 112 | default['gitlab']['gitlab-rails']['db_socket'] = nil |
113 | 113 | |
... | ... | @@ -155,12 +155,11 @@ default['gitlab']['postgresql']['shell'] = "/bin/sh" |
155 | 155 | default['gitlab']['postgresql']['home'] = "/var/opt/gitlab/postgresql" |
156 | 156 | default['gitlab']['postgresql']['user_path'] = "/opt/gitlab/embedded/bin:/opt/gitlab/bin:$PATH" |
157 | 157 | default['gitlab']['postgresql']['sql_user'] = "gitlab" |
158 | -default['gitlab']['postgresql']['sql_password'] = "snakepliskin" | |
159 | 158 | default['gitlab']['postgresql']['port'] = 5432 |
160 | -default['gitlab']['postgresql']['listen_address'] = 'localhost' | |
159 | +default['gitlab']['postgresql']['listen_address'] = nil | |
161 | 160 | default['gitlab']['postgresql']['max_connections'] = 200 |
162 | -default['gitlab']['postgresql']['md5_auth_cidr_addresses'] = [ ] | |
163 | -default['gitlab']['postgresql']['trust_auth_cidr_addresses'] = [ '127.0.0.1/32', '::1/128' ] | |
161 | +default['gitlab']['postgresql']['md5_auth_cidr_addresses'] = [] | |
162 | +default['gitlab']['postgresql']['trust_auth_cidr_addresses'] = [] | |
164 | 163 | default['gitlab']['postgresql']['shmmax'] = kernel['machine'] =~ /x86_64/ ? 17179869184 : 4294967295 |
165 | 164 | default['gitlab']['postgresql']['shmall'] = kernel['machine'] =~ /x86_64/ ? 4194304 : 1048575 |
166 | 165 | ... | ... |
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
... | ... | @@ -65,16 +65,12 @@ module Gitlab |
65 | 65 | end |
66 | 66 | end |
67 | 67 | |
68 | - Gitlab['postgresql']['sql_password'] ||= generate_hex(50) | |
69 | 68 | Gitlab['gitlab_rails']['secret_token'] ||= generate_hex(64) |
70 | 69 | |
71 | 70 | if File.directory?("/etc/gitlab") |
72 | 71 | File.open("/etc/gitlab/gitlab-secrets.json", "w") do |f| |
73 | 72 | f.puts( |
74 | 73 | Chef::JSONCompat.to_json_pretty({ |
75 | - 'postgresql' => { | |
76 | - 'sql_password' => Gitlab['postgresql']['sql_password'], | |
77 | - }, | |
78 | 74 | 'gitlab_rails' => { |
79 | 75 | 'secret_token' => Gitlab['gitlab_rails']['secret_token'], |
80 | 76 | } | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb
files/gitlab-cookbooks/gitlab/recipes/postgresql.rb
... | ... | @@ -112,6 +112,13 @@ template pg_hba_config do |
112 | 112 | notifies :restart, 'service[postgresql]' if OmnibusHelper.should_notify?("postgresql") |
113 | 113 | end |
114 | 114 | |
115 | +template File.join(postgresql_data_dir, "pg_ident.conf") do | |
116 | + owner node['gitlab']['postgresql']['username'] | |
117 | + mode "0644" | |
118 | + variables(node['gitlab']['postgresql'].to_hash) | |
119 | + notifies :restart, 'service[postgresql]' if OmnibusHelper.should_notify?("postgresql") | |
120 | +end | |
121 | + | |
115 | 122 | should_notify = OmnibusHelper.should_notify?("postgresql") |
116 | 123 | |
117 | 124 | runit_service "postgresql" do |
... | ... | @@ -141,9 +148,9 @@ bin_dir = "/opt/gitlab/embedded/bin" |
141 | 148 | db_name = "gitlabhq_production" |
142 | 149 | |
143 | 150 | sql_user = node['gitlab']['postgresql']['sql_user'] |
144 | -sql_user_passwd = node['gitlab']['postgresql']['sql_password'] | |
145 | 151 | |
146 | -execute "#{bin_dir}/psql --port #{pg_port} -d template1 -c \"CREATE USER #{sql_user} WITH ENCRYPTED PASSWORD '#{sql_user_passwd}'\"" do | |
152 | +execute "create #{sql_user} database user" do | |
153 | + command "#{bin_dir}/psql --port #{pg_port} -d template1 -c \"CREATE USER #{sql_user}\"" | |
147 | 154 | user pg_user |
148 | 155 | not_if { !pg_helper.is_running? || pg_helper.sql_user_exists? } |
149 | 156 | end | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/database.yml.erb
... | ... | @@ -7,8 +7,8 @@ production: |
7 | 7 | encoding: <%= @db_encoding %> |
8 | 8 | database: <%= @db_database %> |
9 | 9 | pool: <%= @db_pool %> |
10 | - username: "<%= @db_username %>" | |
11 | - password: "<%= @db_password %>" | |
12 | - host: <%= @db_host %> | |
10 | + username: <%= single_quote(@db_username) %> | |
11 | + password: <%= single_quote(@db_password) %> | |
12 | + host: <%= single_quote(@db_host) %> | |
13 | 13 | port: <%= @db_port %> |
14 | - socket: <%= @db_socket %> | |
14 | + socket: <%= single_quote(@db_socket) %> | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/pg_hba.conf.erb
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | # TYPE DATABASE USER CIDR-ADDRESS METHOD |
68 | 68 | |
69 | 69 | # "local" is for Unix domain socket connections only |
70 | -local all all trust | |
70 | +local all all peer map=gitlab | |
71 | 71 | |
72 | 72 | <% node['gitlab']['postgresql']['trust_auth_cidr_addresses'].each do |cidr| %> |
73 | 73 | host all all <%= cidr %> trust | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/pg_ident.conf.erb
0 → 100644
... | ... | @@ -0,0 +1,45 @@ |
1 | +# PostgreSQL User Name Maps | |
2 | +# ========================= | |
3 | +# | |
4 | +# Refer to the PostgreSQL documentation, chapter "Client | |
5 | +# Authentication" for a complete description. A short synopsis | |
6 | +# follows. | |
7 | +# | |
8 | +# This file controls PostgreSQL user name mapping. It maps external | |
9 | +# user names to their corresponding PostgreSQL user names. Records | |
10 | +# are of the form: | |
11 | +# | |
12 | +# MAPNAME SYSTEM-USERNAME PG-USERNAME | |
13 | +# | |
14 | +# (The uppercase quantities must be replaced by actual values.) | |
15 | +# | |
16 | +# MAPNAME is the (otherwise freely chosen) map name that was used in | |
17 | +# pg_hba.conf. SYSTEM-USERNAME is the detected user name of the | |
18 | +# client. PG-USERNAME is the requested PostgreSQL user name. The | |
19 | +# existence of a record specifies that SYSTEM-USERNAME may connect as | |
20 | +# PG-USERNAME. | |
21 | +# | |
22 | +# If SYSTEM-USERNAME starts with a slash (/), it will be treated as a | |
23 | +# regular expression. Optionally this can contain a capture (a | |
24 | +# parenthesized subexpression). The substring matching the capture | |
25 | +# will be substituted for \1 (backslash-one) if present in | |
26 | +# PG-USERNAME. | |
27 | +# | |
28 | +# Multiple maps may be specified in this file and used by pg_hba.conf. | |
29 | +# | |
30 | +# No map names are defined in the default configuration. If all | |
31 | +# system user names and PostgreSQL user names are the same, you don't | |
32 | +# need anything in this file. | |
33 | +# | |
34 | +# This file is read on server startup and when the postmaster receives | |
35 | +# a SIGHUP signal. If you edit the file on a running system, you have | |
36 | +# to SIGHUP the postmaster for the changes to take effect. You can | |
37 | +# use "pg_ctl reload" to do that. | |
38 | + | |
39 | +# Put your actual configuration here | |
40 | +# ---------------------------------- | |
41 | + | |
42 | +# MAPNAME SYSTEM-USERNAME PG-USERNAME | |
43 | +gitlab <%= node['gitlab']['user']['username'] %> <%= node['gitlab']['postgresql']['sql_user'] %> | |
44 | +# Default to a 1-1 mapping between system usernames and Postgres usernames | |
45 | +gitlab /^(.*)$ \1 | ... | ... |