-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth-username-maps.html
More file actions
160 lines (159 loc) · 15.8 KB
/
auth-username-maps.html
File metadata and controls
160 lines (159 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>20.2. ユーザ名マップ</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="auth-pg-hba-conf.html" title="20.1. pg_hba.confファイル" /><link rel="next" href="auth-methods.html" title="20.3. 認証方式" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 12.4文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="client-authentication.html" title="第20章 クライアント認証">第20章 クライアント認証</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?title=version 12.4 auth-username-maps.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-pg-hba-conf.html" title="20.1. pg_hba.confファイル">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="第20章 クライアント認証">上へ</a></td><td width="60%" align="center">20.2. ユーザ名マップ</td><td width="20%" align="right"> <a accesskey="n" href="auth-methods.html" title="20.3. 認証方式">次へ</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-USERNAME-MAPS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">20.2. ユーザ名マップ</h2></div></div></div><span class="original">
<title>User Name Maps</title>
</span><a id="id-1.6.7.9.2" class="indexterm"></a><p>
<span class="original">
When using an external authentication system such as Ident or GSSAPI,
the name of the operating system user that initiated the connection
might not be the same as the database user (role) that is to be used.
In this case, a user name map can be applied to map the operating system
user name to a database user. To use user name mapping, specify
<literal>map</literal>=<replaceable>map-name</replaceable>
in the options field in <filename>pg_hba.conf</filename>. This option is
supported for all authentication methods that receive external user names.
Since different mappings might be needed for different connections,
the name of the map to be used is specified in the
<replaceable>map-name</replaceable> parameter in <filename>pg_hba.conf</filename>
to indicate which map to use for each individual connection.
</span>
identやGSSAPIといった外部の認証システムを使用する場合は、接続を開始したオペレーティングシステムのユーザ名が接続先のデータベースユーザ(ロール)名と同じであるとは限りません。
ユーザ名マップを使用するには、<code class="filename">pg_hba.conf</code>内で<code class="literal">map</code>=<em class="replaceable"><code>map-name</code></em>オプションを指定してください。
このオプションは、外部ユーザ名を受け取るすべての認証方式をサポートしています。
異なる接続に対して、異なるマップが必要となる可能性があります。そのため、それぞれの接続に対して使用されるマップを指定するために、使用するマップの名称は<code class="filename">pg_hba.conf</code>内の<em class="replaceable"><code>map-name</code></em>パラメータで指定されます。
</p><p>
<span class="original">
User name maps are defined in the ident map file, which by default is named
<filename>pg_ident.conf</filename><indexterm><primary>pg_ident.conf</primary></indexterm>
and is stored in the
cluster's data directory. (It is possible to place the map file
elsewhere, however; see the <xref linkend="guc-ident-file"/>
configuration parameter.)
The ident map file contains lines of the general form:
</span>
ユーザ名マップはidentマップファイルに定義されています。デフォルトではファイル名は<code class="filename">pg_ident.conf</code><a id="id-1.6.7.9.4.2" class="indexterm"></a>で
クラスタのデータディレクトリに保存されています。(他の場所にも保存できますが、詳細は<a class="xref" href="runtime-config-file-locations.html#GUC-IDENT-FILE">ident_file</a>設定パラメータを参照してください。)
identマップファイルは一般的な形式の行を含んでいます。
</p><pre class="synopsis">
<em class="replaceable"><code>map-name</code></em> <em class="replaceable"><code>system-username</code></em> <em class="replaceable"><code>database-username</code></em>
</pre><p>
<span class="original">
Comments and whitespace are handled in the same way as in
<filename>pg_hba.conf</filename>. The
<replaceable>map-name</replaceable> is an arbitrary name that will be used to
refer to this mapping in <filename>pg_hba.conf</filename>. The other
two fields specify an operating system user name and a matching
database user name. The same <replaceable>map-name</replaceable> can be
used repeatedly to specify multiple user-mappings within a single map.
</span>
コメントと空白は<code class="filename">pg_hba.conf</code>と同様に扱われます。 <em class="replaceable"><code>map-name</code></em>は
<code class="filename">pg_hba.conf</code>内で参照される任意の名称です。
他の2つのフィールドは、どのオペレーティングシステムユーザが、どのデータベースユーザに接続することを許可されているかを指定しています。
同じ<em class="replaceable"><code>map-name</code></em>は、1つのマップ内でユーザをマップするために繰り返し使用されます。
</p><p>
<span class="original">
There is no restriction regarding how many database users a given
operating system user can correspond to, nor vice versa. Thus, entries
in a map should be thought of as meaning <quote>this operating system
user is allowed to connect as this database user</quote>, rather than
implying that they are equivalent. The connection will be allowed if
there is any map entry that pairs the user name obtained from the
external authentication system with the database user name that the
user has requested to connect as.
</span>
どれだけのデータベースユーザがオペレーティングシステムのユーザに対して一致しているか、またその逆に対しても制限はありません。
よってマップ内のエントリは、それらが等しいというよりもむしろ
<span class="quote">「<span class="quote">このオペレーティングシステムのユーザはこのデータベースユーザとして接続する</span>」</span>という意味になります。
もし外部の認証システムから得られたユーザ名と接続要求を行ったデータベースユーザ名が対となるエントリがマップ内にある場合は、接続は許可されます。
</p><p>
<span class="original">
If the <replaceable>system-username</replaceable> field starts with a slash (<literal>/</literal>),
the remainder of the field is treated as a regular expression.
(See <xref linkend="posix-syntax-details"/> for details of
<productname>PostgreSQL</productname>'s regular expression syntax.) The regular
expression can include a single capture, or parenthesized subexpression,
which can then be referenced in the <replaceable>database-username</replaceable>
field as <literal>\1</literal> (backslash-one). This allows the mapping of
multiple user names in a single line, which is particularly useful for
simple syntax substitutions. For example, these entries
</span>
もし<em class="replaceable"><code>system-username</code></em>フィールドがスラッシュ(<code class="literal">/</code>)で始まっている場合は、
このフィールドの残りは正規表現として扱われます。
(<span class="productname">PostgreSQL</span>の正規表現構文の詳細については<a class="xref" href="functions-matching.html#POSIX-SYNTAX-DETAILS" title="9.7.3.1. 正規表現の詳細">9.7.3.1</a>を参照してください。)
正規表現は単一検索や括弧を使用した表現、<em class="replaceable"><code>database-username</code></em>フィールドで<code class="literal">\1</code>(バックスラッシュ-1)で参照されるような表現を含みます。
これにより、1行で複数のユーザ名のマップが可能となり、簡単な構文で特に使いやすくなります。例を以下に示します。
</p><pre class="programlisting">
mymap /^(.*)@mydomain\.com$ \1
mymap /^(.*)@otherdomain\.com$ guest
</pre><p>
<span class="original">
will remove the domain part for users with system user names that end with
<literal>@mydomain.com</literal>, and allow any user whose system name ends with
<literal>@otherdomain.com</literal> to log in as <literal>guest</literal>.
</span>
上記のエントリでは、<code class="literal">@mydomain.com</code>で終わるシステムユーザ名のドメイン部分を削除して、
<code class="literal">@otherdomain.com</code>で終わるシステムユーザ名が<code class="literal">guest</code>としてログインすることを許可します。
</p><div class="tip"><h3 class="title">ヒント</h3><p>
<span class="original">
Keep in mind that by default, a regular expression can match just part of
a string. It's usually wise to use <literal>^</literal> and <literal>$</literal>, as
shown in the above example, to force the match to be to the entire
system user name.
</span>
デフォルトでは正規表現は、文字列の一部を一致させることに注意してください。
上記の例で示したように、システムユーザ名全体を強制的に一致させるために<code class="literal">^</code>や<code class="literal">$</code>を使用すると有用です。
</p></div><p>
<span class="original">
The <filename>pg_ident.conf</filename> file is read on start-up and
when the main server process receives a
<systemitem>SIGHUP</systemitem><indexterm><primary>SIGHUP</primary></indexterm>
signal. If you edit the file on an
active system, you will need to signal the postmaster
(using <literal>pg_ctl reload</literal>, calling the SQL function
<function>pg_reload_conf()</function>, or using <literal>kill
-HUP</literal>) to make it re-read the file.
</span>
<code class="filename">pg_ident.conf</code>ファイルは起動時と、メインサーバのプロセスが
<span class="systemitem">SIGHUP</span><a id="id-1.6.7.9.8.3" class="indexterm"></a>を受信したときに読み込まれます。
起動しているシステムで編集した場合は、ファイルを再読み込みするために(<code class="literal">pg_ctl reload</code>の使用、SQL関数<code class="function">pg_reload_conf()</code>の呼び出し、または<code class="literal">kill -HUP</code>を使用して)postmasterにシグナルを送信する必要があります。
</p><p>
<span class="original">
A <filename>pg_ident.conf</filename> file that could be used in
conjunction with the <filename>pg_hba.conf</filename> file in <xref
linkend="example-pg-hba.conf"/> is shown in <xref
linkend="example-pg-ident.conf"/>. In this example, anyone
logged in to a machine on the 192.168 network that does not have the
operating system user name <literal>bryanh</literal>, <literal>ann</literal>, or
<literal>robert</literal> would not be granted access. Unix user
<literal>robert</literal> would only be allowed access when he tries to
connect as <productname>PostgreSQL</productname> user <literal>bob</literal>, not
as <literal>robert</literal> or anyone else. <literal>ann</literal> would
only be allowed to connect as <literal>ann</literal>. User
<literal>bryanh</literal> would be allowed to connect as either
<literal>bryanh</literal> or as <literal>guest1</literal>.
</span>
<code class="filename">pg_ident.conf</code>ファイルは、<code class="filename">pg_hba.conf</code>ファイルと結合して使用されます。
<a class="xref" href="auth-username-maps.html#EXAMPLE-PG-IDENT.CONF" title="例20.2 pg_ident.confファイルの例">例 20.2</a>に<a class="xref" href="auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF" title="例20.1 pg_hba.confの項目の例">例 20.1</a>の例があります。
この例では、192.168のネットワーク内のマシンにログインしている、
オペレーティングシステムのユーザ名で<code class="literal">bryanh</code>、<code class="literal">ann</code>、<code class="literal">robert</code>以外の誰もが、アクセスを許可されていません。
Unixユーザ<code class="literal">robert</code>は<span class="productname">PostgreSQL</span>ユーザである<code class="literal">bob</code>として接続しようとした時のみ
アクセス可能で、 <code class="literal">robert</code>や他の名前ではアクセスできません。
<code class="literal">ann</code>は<code class="literal">ann</code>として接続した時のみ許可され、<code class="literal">bryanh</code>は<code class="literal">bryanh</code>自身もしくは<code class="literal">guest1</code>として
アクセスが可能となります。
</p><div class="example" id="EXAMPLE-PG-IDENT.CONF"><p class="title"><strong>例20.2 <code class="filename">pg_ident.conf</code>ファイルの例</strong></p><div class="example-contents"><span class="original">
<title>An Example <filename>pg_ident.conf</filename> File</title>
</span><pre class="programlisting">
# MAPNAME SYSTEM-USERNAME PG-USERNAME
omicron bryanh bryanh
omicron ann ann
<span class="original">
# bob has user name robert on these machines
</span>
# bobはこれらのマシン内でrobertというユーザ名を持っています。
omicron robert bob
<span class="original">
# bryanh can also connect as guest1
</span>
# bryanhはguest1としても接続可能です。
omicron bryanh guest1
</pre></div></div><br class="example-break" /></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-pg-hba-conf.html">前へ</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html">上へ</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-methods.html">次へ</a></td></tr><tr><td width="40%" align="left" valign="top">20.1. <code class="filename">pg_hba.conf</code>ファイル </td><td width="20%" align="center"><a accesskey="h" href="index.html">ホーム</a></td><td width="40%" align="right" valign="top"> 20.3. 認証方式</td></tr></table></div></body></html>