forked from i0seph/pgdoc-kr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient-auth.sgml
1850 lines (1650 loc) · 93.1 KB
/
client-auth.sgml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- doc/src/sgml/client-auth.sgml -->
<chapter id="client-authentication">
<title>클라이언트 인증</title>
<indexterm zone="client-authentication">
<primary>클라이언트 인증</primary>
</indexterm>
<para>
클라이언트 애플리케이션이 데이터베이스 서버에 연결하는 경우 어떤 <productname>PostgreSQL</productname> 데이터베이스 사용자 이름으로 연결할 것인지 지정하는데, 이것은 특정 사용자로 Unix 컴퓨터에 로그인하는 것과 매우 유사하다.
SQL 환경 내에서 사용 중인 데이터베이스 사용자 이름은 데이터베이스 개체에 대한 액세스 권한을 결정한다. 자세한 내용은 <xref linkend="user-manag"/>을 참고 바란다. 따라서 연결 가능한 데이터베이스 사용자를 제한하는 것이 중요하다.
</para>
<note>
<para>
<xref linkend="user-manag"/>에서 설명한 대로 <productname>PostgreSQL</productname>은 실제로 <quote>role</quote> 면에서 권한을 관리한다. 이 장에서는 <firstterm>데이터베이스 사용자</firstterm>가 <quote><literal>LOGIN</literal> 권한이 있는 role</quote>이라는 의미로 일관되게 사용된다.
</para>
</note>
<para>
<firstterm>인증</firstterm>은 데이터베이스 서버가 클라이언트 ID를 구축하는 프로세스이며, 더 나아가 요청된 데이터베이스 사용자 이름으로 클라이언트 애플리케이션(또는 클라이언트 애플리케이션을 실행하는 사용자)의 연결을 허용할 것인지 결정하는 프로세스이다.
</para>
<para>
<productname>PostgreSQL</productname>는 서로 다른 여러 가지 클라이언트 인증 방법을 제공한다.
특정 클라이언트 연결을 인증하는 데 사용되는 방법은 (클라이언트) 호스트 주소, 데이터베이스 및 사용자를 기준으로 선택할 수 있다.
</para>
<para>
<productname>PostgreSQL</productname> 데이터베이스 사용자 이름은 서버가 실행되는 운영 체제의 사용자 이름과 논리적으로 별개이다. 특정 서버의 모든 사용자도 서버 머신에 계정을 가질 수 있지만 운영 체제 사용자 이름과 일치하는 데이터베이스 사용자 이름을 할당하는 것이 합당하다.
그러나, 원격 연결을 수용하는 서버에는 로컬 운영 체제 계정이 없는 데이터베이스 사용자가 다수일 수 있으며, 이런 경우 데이터베이스 사용자 이름과 OS 사용자 이름을 연결 짓는 것은 불필요하다.
</para>
<sect1 id="auth-pg-hba-conf">
<title>The <filename>pg_hba.conf</filename> 파일</title>
<indexterm zone="auth-pg-hba-conf">
<primary>pg_hba.conf</primary>
</indexterm>
<para>
클라이언트 인증은 전통적으로 이름이 <filename>pg_hba.conf</filename>이고 데이터베이스 클러스터의 데이터 디렉터리에 저장되는 환경 설정 파일로 제어된다. (<acronym>HBA</acronym>는 호스트 기반 인증(host-based authentication)의 약어이다.)
기본 <filename>pg_hba.conf</filename> 파일은 데이터 디렉터리가 <command>initdb</command>에 의해 초기화될 때 설치된다. 인증 환경 설정 파일을 다른 곳에 배치하는 것도 가능하다. <xref linkend="guc-hba-file"/> 환경 설정 파일을 참조 바란다.
</para>
<para>
<filename>pg_hba.conf</filename> 파일의 일반 형식은 한 줄당 하나씩 있는 레코드 세트이다. 빈 줄은 무시된다. <literal>#</literal> 주석 문자 뒤의 텍스트도 무시된다. 레코드는 줄을 바꿔서 이어질 수 없다. 레코드는 여러 개의 필드로 구성되며, 공백 및/또는 탭으로 구분된다.
필드 값에 큰 따옴표를 사용하면 필드에 공백을 포함할 수 있다. 데이터베이스, 사용자 또는 주소 필드의 키워드에 따옴표를 사용하면(예: <literal>all</literal> 또는 <literal>replication</literal>) 단어는 자체의 특수한 의미를 상실하고 해당 이름의 데이터베이스, 사용자 또는 호스트와 동일하게 된다.
</para>
<para>
각 레코드는 이러한 매개 변수와 일치하는 연결에 사용되는 연결 유형, 클라이언트 IP 주소 범위(연결 유형에 해당하는 경우), 데이터베이스 이름, 사용자 이름 및 인증 방법을 지정한다.
연결 타입, 클라이언트 주소, 요청된 데이터베이스 및 사용자 이름이 일치하는 첫 번째 레코드는 인증을 수행할 때 사용된다. <quote>제어 이동(fall-through)</quote> 또는 <quote>백업</quote>은 없다. 레코드 하나가 선택되고 인증이 실패한 경우 후속 레코드는 고려되지 않는다.
일치하는 레코드가 없으면 액세스가 거부된다.
</para>
<para>
레코드는 다음 여러 형식이다:
<synopsis>
local <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostgssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostgssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-options</replaceable></optional>
</synopsis>
필드의 의미는 다음과 같다.
<variablelist>
<varlistentry>
<term><literal>local</literal></term>
<listitem>
<para>
이 레코드는 Unix 도메인 소켓을 사용한 연결 시도와 일치한다. 이러한 유형의 레코드 없이 Unix 도메인 소켓 연결은 불가능 하다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>host</literal></term>
<listitem>
<para>
This record matches connection attempts made using TCP/IP.
<literal>host</literal> records match
<acronym>SSL</acronym> or non-<acronym>SSL</acronym> connection
attempts as well as <acronym>GSSAPI</acronym> encrypted or
non-<acronym>GSSAPI</acronym> encrypted connection attempts.
</para>
<note>
<para>
기본 동작이 로컬 루프백 주소 <literal>localhost</literal>에 대해서만 TCP/IP 연결을 listen하는 것이므로 <xref linkend="guc-listen-addresses"/> 환경 설정 매개 변수에 적절한 값으로 서버가 시작되지 않으면 원격 TCP/IP 연결이 불가능하다.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>hostssl</literal></term>
<listitem>
<para>
이 레코드는 TCP/IP를 사용한 연결 시도와 일치하지만, <acronym>SSL</acronym> 암호화를 사용한 연결에만 해당된다.
</para>
<para>
이 옵션을 사용하려면 서버는 <acronym>SSL</acronym> 지원이 내장되어 있어야 한다. 또한
<acronym>SSL</acronym>은 <xref linkend="guc-ssl"/> 환경 설정 매개 변수 값
지정으로 활성화되어야 한다(자세한 내용은 <xref linkend="ssl-tcp"/> 참조).
한편, <literal>hostssl</literal> 레코드 지정으로 접속 예외 처리 되는
정보는 경고 로그를 남기지 않는다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>hostnossl</literal></term>
<listitem>
<para>
이 레코드 유형은 <literal>hostssl</literal>과는 반대로 동작한다.
<acronym>SSL</acronym>을 사용하지 않는 TCP/IP 상의 연결 시도에 대해서만 일치한다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>hostgssenc</literal></term>
<listitem>
<para>
This record matches connection attempts made using TCP/IP,
but only when the connection is made with <acronym>GSSAPI</acronym>
encryption.
</para>
<para>
To make use of this option the server must be built with
<acronym>GSSAPI</acronym> support. Otherwise,
the <literal>hostgssenc</literal> record is ignored except for logging
a warning that it cannot match any connections.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>hostnogssenc</literal></term>
<listitem>
<para>
This record type has the opposite behavior of <literal>hostgssenc</literal>;
it only matches connection attempts made over
TCP/IP that do not use <acronym>GSSAPI</acronym> encryption.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>database</replaceable></term>
<listitem>
<para>
이 레코드가 일치하는 데이터베이스 이름을 지정한다. <literal>all</literal> 값은 모든 데이터베이스와 일치하도록 지정한다. <literal>sameuser</literal> 값은 요청된 데이터베이스가 요청된 사용자와 이름이 동일한 경우에 레코드가 일치하도록 지정한다.
<literal>samerole</literal> 값은 요청된 사용자가 요청된 데이터베이스와 이름이 동일한 role의 멤버여야 하는지 지정한다. (<literal>samegroup</literal>은 폐지되었지만 <literal>samerole</literal>은 계속 쓸 수 있다.)
수퍼유저는 직간접적으로 role의 명시적인 멤버가 아닐 경우, 단지 수퍼유저라는 이유로 <literal>samerole</literal>에 대한 role의 멤버로 간주되지 않는다. <literal>replication</literal> 값은 물리 복제 연결이 요청되는 경우 레코드가 일치하도록 지정한다(복제 연결은 특정 데이터베이스를 지정하지는 않는다).
이 경우가 아니라면 특정 <productname>PostgreSQL</productname> 데이터베이스의 이름으로 사용된다. 쉼표로 구분해서 데이터베이스 이름을 여러 개 쓸 수 있다. 데이터베이스 이름이 포함된 파일은 파일 이름 앞에 <literal>@</literal>를 붙여서 지정 가능하다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>user</replaceable></term>
<listitem>
<para>
이 레코드와 일치하는 데이터베이스 사용자 이름을 지정한다. <literal>all</literal> 값은 모든 사용자와 일치하도록 지정한다. 이 외에는, 특정한 데이터베이스 사용자의 이름이거나, 앞에 <literal>+</literal>를 붙인 그룹 이름이다. (<productname>PostgreSQL</productname>에서는 사용자와 그룹 이름 간에 실제로 차이는 없다.
<literal>+</literal> 마크는 실제로 <quote>이 role의 직접 또는 간접 멤버인 아무 role과 일치함</quote>을 의미하며, <literal>+</literal> 마크가 없는 이름은 유일하게 특정 role과 일치한다.)
이러한 이유로, 수퍼유저는 단지 수퍼유저라는 이유 때문이 아니라, 직간접적으로 role의 명시적 멤버인 경우에만 role 멤버로 간주된다.
쉼표로 구분함해서 사용자 이름을 여러 개 쓸 수 있다. 사용자 이름이 포함된 파일은 파일 이름 앞에 <literal>@</literal>를 붙여서 지정 가능하다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>address</replaceable></term>
<listitem>
<para>
이 레코드가 일치하는 클라이언트 머신 주소(들)를 지정한다. 이 필드는
호스트 이름, IP 주소 범위 또는 아래 설명된 특수 키워드 중 하나를
포함할 수 있다.
</para>
<para>
IP 주소 대역은 <acronym>CIDR</acronym> 표기법을 사용하며,
빗금 기호를 기준으로 왼쪽은 시작 주소, 오른쪽은 마스크 길이를 지정한다.
마스크 길이는 일치해야 하는 클라이언트 IP 주소의 상위 비트 수를 나타낸다.
이것의 오른쪽에 있는 비트는 주어진 IP 주소에서 0이어야 한다.
IP 주소, <literal>/</literal> 및 CIDR 마스크 길이 사이에 공백이 있으면 안 된다.
</para>
<para>
이러한 방법으로 지정된 IPv4 주소 범위의 전형적인 예시는
단일 호스트의 경우 <literal>172.20.143.89/32</literal>,
소규모 네트워크의 경우 <literal>172.20.143.0/24</literal>,
대규모 네트워크의 경우 <literal>10.6.0.0/16</literal>일 수 있다.
IPv6 주소인 경우는,
단일 호스트 루프백 주소는 <literal>::1/128</literal>,
소규모 네트워크인 경우는 <literal>fe80::7a31:c1ff:0000:0000/96</literal>
형태이다.
<literal>0.0.0.0/0</literal>은 모든 IPv4 주소를 나타내며
<literal>::0/0</literal>은 모든 IPv6 주소를 나타낸다.
단일 호스트를 지정하려면 IPv4의 마스크 길이값으로 32를 사용하고
IPv6의 경우 128을 사용해야 한다.
<acronym>CIDR</acronym> 표기의 시작 주소를 지정할 때는 끝 값이 0이어도
생략할 수 없음을 주의 해야 한다.
</para>
<para>
클라이언트가 IPv4 주소로 연결을 시도하면, IPv4 주소 항목에서만 인증 처리를 하고,
IPv6로 연결을 시도하면, IPv6 주소 항목에서만 인증 처리를 한다.
즉, <literal>127.0.0.1</literal> 주소와 <literal>::1/128</literal> 같은
루프백일지라도 각각 처리 된다.
IPv6 형식의 항목은 표시된 주소가 IPv4-in-IPv6 범위 내이더라도 IPv6 연결만
고려한다.
IPv6 형식의 항목은 시스템의 C 라이브러리가 IPv6 주소를 지원하지 않는 경우 거부된다.
</para>
<para>
사용자는 아무 IP 주소나 일치하도록 <literal>all</literal>을 쓸 수도 있고,
서버의 자체 IP 주소 아무거나 일치하도록 <literal>samehost</literal>를
쓸 수도 있고, 서버가 직접 연결되는 서브넷의 아무 주소나
일치하도록 <literal>samenet</literal>을 쓸 수도 있다.
</para>
<para>
호스트 이름이 지정된 경우(IP 주소 범위가 아니거나 위에서 설명한 특수 예약어로
호스트 이름을 지정한 경우), 해당 이름은 클라이언트 IP 주소의
역방향 이름 분석 결과와 비교된다(예: DNS가 사용되는 경우 역방향 DNS 조회).
호스트 이름 비교는 대소문자를 구분하지 않는다.
일치가 있는 경우, 순방향 이름 분석(예: 순방향 DNS 조회)은 분석할 주소가 클라이언트의 IP 주소와 동일한지 검사하기 위해 호스트 이름에 대해 수행한다. 양방향으로 일치할 경우 항목이 일치하는 것으로 간주된다.
(<filename>pg_hba.conf</filename>에서 사용되는 호스트 이름은 클라이언트 IP 주소의 주소-이름 분석(address-to-name resolution)이 리턴하는 것이어야 하며, 아닐 경우 줄이 일치하지 않게 된다.
일부 호스트 이름 데이터베이스는 IP 주소를 호스트 이름 여러 개와 연결하는 것을 허용하지만, IP 주소를 분석하도록 요청된 경우 운영 체제는 호스트 이름을 하나만 리턴한다.
</para>
<para>
점(<literal>.</literal>)으로 시작되는 호스트 이름 규격은 실제 호스트 이름의 접미사와 일치한다.
따라서, <literal>.example.com</literal>은 <literal>foo.example.com</literal>과 일치하게 된다(<literal>example.com</literal>만으로는 일치하지 않음).
</para>
<para>
호스트 이름이 <filename>pg_hba.conf</filename>에 지정된 경우 이름 분석이 상당히 빠른지 확인해야 한다.
<command>nscd</command> 같은 로컬 이름 분석 캐시를 설정하는 것이 유리할 수 있다.
또한 사용자는 환경 설정 매개 변수 <varname>log_hostname</varname>을 활성화하여 로그의 IP 주소 대신 클라이언트의 호스트 이름을 볼 수 있다.
</para>
<para>
이 필드는 <literal>local</literal> 레코드에는 사용할 수 없다.
</para>
<note>
<para>
클라이언트 IP 주소의 역방향 조회를 비롯한 두 가지 이름 분석 같이 이렇게 복잡한 방식으로 호스트 이름을 처리하는 이유를 궁금해 하는 사용자도 있다.
이것은 클라이언트의 역방향 DNS 항목이 설정되지 않았거나 바람직하지 않은 호스트 이름을 넘겨주는 경우에는 기능 사용을 복잡하게 만든다. 이것은 기본적으로 효율성을 위한 것이다.
이와 같은 연결 시도는 기껏해야 두 가지 리졸버(resolver) 조회(역방향 하나 및 순방향 하나)를 시도한다. 일부 주소에 리졸버(resolver) 문제가 있는 경우 이것은 해당 클라이언트만의 문제이다.
순방향 조회만 수행했던 가상적 대안의 구현은 <filename>pg_hba.conf</filename>에 나오는 모든 호스트 이름을 연결 시도할 때마다 분석해야 한다. 이름이 많을 경우 속도가 매우 느려진다.
그리고, 호스트 이름 중 한 가지에 리졸버(resolver) 문제가 있는 경우 이것은 전체의 문제가 된다.
</para>
<para>
또한, 패턴 일치를 위해서는 실제 클라이언트 호스트 이름을 알고 있어야 하므로 역방향 조회는 접미사 일치 기능을 구현할 필요가 있다.
</para>
<para>
이러한 동작은 Apache HTTP 서버 및 TCP 래퍼 같은 다른 유명한 호스트 이름 기반 액세스 제어 구현과 일치한다.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>IP-address</replaceable></term>
<term><replaceable>IP-mask</replaceable></term>
<listitem>
<para>
이 두 필드는 <replaceable>IP-주소</replaceable><literal>/</literal><replaceable>마스크길이</replaceable>
표기의 대안으로 사용될 수 있다. 마스크 길이를 지정하는 대신,
실제 마스크를 지정한다.
예를 들면, <literal>255.0.0.0</literal>은 IPv4 CIDR 마스크 길이 8을 나타내고,
<literal>255.255.255.255</literal>는 CIDR 마스크 길이 32를 나타낸다.
</para>
<para>
이 필드는 <literal>local</literal> 레코드에는 사용할 수 없다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>auth-method</replaceable></term>
<listitem>
<para>
연결이 이 레코드와 일치할 때 사용하는 인증 방법을 지정한다.
가능한 선택안이 여기에 요약되어 있다. 자세한 내용은 <xref linkend="auth-methods"/>을 참조 바란다.
<variablelist>
<varlistentry>
<term><literal>trust</literal></term>
<listitem>
<para>
무조건 연결을 허용한다. 이 방법은 패스워드나 다른 인증 없이 임의의 <productname>PostgreSQL</productname> 데이터베이스 사용자로 로그인하여 누구나 <productname>PostgreSQL</productname> 데이터베이스 서버에 연결할 수 있다.
자세한 내용은 <xref
linkend="auth-trust"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>reject</literal></term>
<listitem>
<para>
무조건 연결을 거부한다. 이것은 그룹에서 특정 호스트를 <quote>필터링</quote>할 때 유용하다.
예를 들면, <literal>reject</literal> 줄은 특정 호스트의 연결을 차단하고, 그 이후의 줄은 특정 네트워크에서 나머지 호스트의 연결을 허용한다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>scram-sha-256</literal></term>
<listitem>
<para>
Perform SCRAM-SHA-256 authentication to verify the user's
password. See <xref linkend="auth-password"/> for details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>md5</literal></term>
<listitem>
<para>
Perform SCRAM-SHA-256 or MD5 authentication to verify the
user's password. See <xref linkend="auth-password"/>
for details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>password</literal></term>
<listitem>
<para>
클라이언트가 인증을 위해 암호화되지 않은 패스워드를 제공해야 한다.
패스워드는 네트워크 상에서 일반 텍스트로 전송되므로 신뢰하지 않는 네트워크에서 이것을 사용하면 안 된다.
자세한 내용은 <xref linkend="auth-password"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gss</literal></term>
<listitem>
<para>
GSSAPI를 사용하여 사용자를 인증한다. 이것은
TCP/IP 연결에서만 사용할 수 있다. 자세한 내용은 <xref
linkend="gssapi-auth"/>을 참조 바란다. 이것은
GSSAPI 암호화와 함께 사용할 있다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>sspi</literal></term>
<listitem>
<para>
SSPI를 사용하여 사용자를 인증한다. 이것은 Windows에서만 사용할 수 있다. 자세한 내용은 <xref
linkend="sspi-auth"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>ident</literal></term>
<listitem>
<para>
클라이언트의 ident 서버에 접촉함으로써 클라이언트의 운영 체제 사용자 이름을 획득하고, 요청된 데이터베이스 사용자 이름과 일치하는지 확인한다.
Ident 인증은 TCP/IP 연결에서만 사용할 수 있다.
로컬 연결에 대해 지정하는 경우 피어(peer) 인증이 대신 사용된다. 자세한 내용은 <xref linkend="auth-ident"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>peer</literal></term>
<listitem>
<para>
클라이언트의 운영 체제 사용자 이름을 운영 체제에서 획득하고, 요청된 데이터베이스 사용자 이름과 일치하는지 확인한다.
이것은 로컬 연결에서만 사용할 수 있다. 자세한 내용은 <xref linkend="auth-peer"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>ldap</literal></term>
<listitem>
<para>
<acronym>LDAP</acronym> 서버를 사용하여 인증한다. 자세한 내용은 <xref
linkend="auth-ldap"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>radius</literal></term>
<listitem>
<para>
RADIUS 서버를 사용하여 인증한다. 자세한 내용은 <xref
linkend="auth-radius"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>cert</literal></term>
<listitem>
<para>
SSL 클라이언트 인증을 사용하여 인증한다. 자세한 내용은 <xref linkend="auth-cert"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>pam</literal></term>
<listitem>
<para>
운영 체제에서 제공하는 PAM(Pluggable Authentication Modules)을 사용하여 인증한다.
자세한 내용은 <xref
linkend="auth-pam"/>을 참조 바란다.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>bsd</literal></term>
<listitem>
<para>
운영체제에서 제공하는 BSD 인증 서비스를 이용해서 인증한다. 아래
<xref linkend="auth-bsd"/>에서 자세히 설명한다.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>auth-options</replaceable></term>
<listitem>
<para>
<replaceable>auth-method</replaceable> 필드 이후에 인증 방법에 대한 옵션을 지정하는 <replaceable>name</replaceable><literal>=</literal><replaceable>value</replaceable> 형식의 필드가 있을 수 있다.
인증 방법에서 사용할 수 있는 옵션에 대한 자세한 내용은 아래에 나와 있다.
</para>
<para>
In addition to the method-specific options listed below, there is one
method-independent authentication option <literal>clientcert</literal>, which
can be specified in any <literal>hostssl</literal> record.
This option can be set to <literal>verify-ca</literal> or
<literal>verify-full</literal>. Both options require the client
to present a valid (trusted) SSL certificate, while
<literal>verify-full</literal> additionally enforces that the
<literal>cn</literal> (Common Name) in the certificate matches
the username or an applicable mapping.
This behavior is similar to the <literal>cert</literal> authentication
method (see <xref linkend="auth-cert"/>) but enables pairing
the verification of client certificates with any authentication
method that supports <literal>hostssl</literal> entries.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<literal>@</literal> 구문이 포함된 파일은, 공백 또는 쉼표로 구분된 이름 목록으로 읽는다.
<filename>pg_hba.conf</filename>처럼 <literal>#</literal>로 표시된 주석 및 중첩된 <literal>@</literal> 구문이 허용된다. 파일 이름 뒤에 <literal>@</literal>가 나오는 것이 절대 경로가 아니면 참고 파일이 있는 디렉터리의 상대 경로로 취급된다.
</para>
<para>
<filename>pg_hba.conf</filename> 레코드는 각 연결 시도에 대해 순차적으로 검사되므로 레코드의 순서는 중요하다. 일반적으로 초기 레코드는 연결 일치 매개 변수는 치밀하고, 인증 방법은 느슨한 반면, 후기 레코드는 일치 매개 변수는 느슨하고 인증 방법은 강력하다.
예를 들면, 로컬 TCP/IP 연결에 대한 <literal>trust</literal> 인증을 사용하려고 하면서 원격 TCP/IP 연결을 원할 수도 있다. 이런 경우 127.0.0.1로부터 연결을 위한 <literal>trust</literal> 인증을 지정한 레코드는 다양한 허용 클라이언트 IP 주소에 대해 패스워드 인증을 지원하는 레코드 앞에 나타난다.
</para>
<para>
<filename>pg_hba.conf</filename> 파일은 시작 시 및 메인 서버 프로세스가 <systemitem>SIGHUP</systemitem><indexterm><primary>SIGHUP</primary></indexterm> 신호를 수신하면 읽어오기 된다.
활성 시스템에서 파일을 편집하는 경우 파일을 다시
읽어오려면 postmaster에 신호를 전송해야 한다
(<literal>pg_ctl reload</literal> 또는 <function>pg_reload_conf()</function>
SQL 함수 호출 또는 <literal>kill -HUP</literal> 사용).
</para>
<note>
<para>
The preceding statement is not true on Microsoft Windows: there, any
changes in the <filename>pg_hba.conf</filename> file are immediately
applied by subsequent new connections.
</para>
</note>
<para>
The system view
<link linkend="view-pg-hba-file-rules"><structname>pg_hba_file_rules</structname></link>
can be helpful for pre-testing changes to the <filename>pg_hba.conf</filename>
file, or for diagnosing problems if loading of the file did not have the
desired effects. Rows in the view with
non-null <structfield>error</structfield> fields indicate problems in the
corresponding lines of the file.
</para>
<tip>
<para>
특수한 데이터베이스에 연결하려면 <filename>pg_hba.conf</filename> 검사만 통과해서는 안 되며 데이터베이스에 대한 <literal>CONNECT</literal> 권한이 사용자에게 있어야 한다.
데이터베이스에 연결 가능한 사용자를 제한하고 싶으면 <filename>pg_hba.conf</filename> 항목에 규칙을 입력하는 것보다 <literal>CONNECT</literal> 권한을 부여/취소하는 것이 일반적으로 쉽다.
</para>
</tip>
<para>
<filename>pg_hba.conf</filename> 항목에 대한 몇 가지 예시가 <xref linkend="example-pg-hba.conf"/>에 나와 있다. 서로 다른 인증 방법에 대한 자세한 내용은 다음 절을 참조 바란다.
</para>
<example id="example-pg-hba.conf">
<title><filename>pg_hba.conf</filename> 항목 예시</title>
<programlisting>
# Allow any user on the local system to connect to any database with
# any database user name using Unix-domain sockets (the default for local
# connections).
#
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
# The same using local loopback TCP/IP connections.
#
# TYPE DATABASE USER ADDRESS METHOD
host all all 127.0.0.1/32 trust
# The same as the previous line, but using a separate netmask column
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all 127.0.0.1 255.255.255.255 trust
# The same over IPv6.
#
# TYPE DATABASE USER ADDRESS METHOD
host all all ::1/128 trust
# The same using a host name (would typically cover both IPv4 and IPv6).
#
# TYPE DATABASE USER ADDRESS METHOD
host all all localhost trust
# Allow any user from any host with IP address 192.168.93.x to connect
# to database "postgres" as the same user name that ident reports for
# the connection (typically the operating system user name).
#
# TYPE DATABASE USER ADDRESS METHOD
host postgres all 192.168.93.0/24 ident
# Allow any user from host 192.168.12.10 to connect to database
# "postgres" if the user's password is correctly supplied.
#
# TYPE DATABASE USER ADDRESS METHOD
host postgres all 192.168.12.10/32 scram-sha-256
# Allow any user from hosts in the example.com domain to connect to
# any database if the user's password is correctly supplied.
#
# Require SCRAM authentication for most users, but make an exception
# for user 'mike', who uses an older client that doesn't support SCRAM
# authentication.
#
# TYPE DATABASE USER ADDRESS METHOD
host all all .example.com md5
host all all .example.com scram-sha-256
# In the absence of preceding "host" lines, these three lines will
# reject all connections from 192.168.54.1 (since that entry will be
# matched first), but allow GSSAPI-encrypted connections from anywhere else
# on the Internet. The zero mask causes no bits of the host IP address to
# be considered, so it matches any host. Unencrypted GSSAPI connections
# (which "fall through" to the third line since "hostgssenc" only matches
# encrypted GSSAPI connections) are allowed, but only from 192.168.12.10.
#
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.54.1/32 reject
hostgssenc all all 0.0.0.0/0 gss
host all all 192.168.12.10/32 gss
# Allow users from 192.168.x.x hosts to connect to any database, if
# they pass the ident check. If, for example, ident says the user is
# "bryanh" and he requests to connect as PostgreSQL user "guest1", the
# connection is allowed if there is an entry in pg_ident.conf for map
# "omicron" that says "bryanh" is allowed to connect as "guest1".
#
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.0.0/16 ident map=omicron
# If these are the only three lines for local connections, they will
# allow local users to connect only to their own databases (databases
# with the same name as their database user name) except for administrators
# and members of role "support", who can connect to all databases. The file
# $PGDATA/admins contains a list of names of administrators. Passwords
# are required in all cases.
#
# TYPE DATABASE USER ADDRESS METHOD
local sameuser all md5
local all @admins md5
local all +support md5
# The last two lines above can be combined into a single line:
local all @admins,+support md5
# The database column can also use lists and file names:
local db1,db2,@demodbs all md5
</programlisting>
</example>
</sect1>
<sect1 id="auth-username-maps">
<title>사용자 이름 맵</title>
<indexterm zone="auth-username-maps">
<primary>사용자 이름 맵</primary>
</indexterm>
<para>
Ident 또는 GSSAPI 같은 외부 인증 시스템을 사용하는 경우, 연결을 시작하는 운영 체제 사용자의 이름은 연결해야 하는 데이터베이스 사용자 이름(롤 이름)과 다를 수 있다.
이런 경우 사용자 이름 맵을 사용하여 운영 체제 사용자 이름과 데이터베이스 사용자 이름을 매핑할 수 있다.
사용자 이름 매핑을 사용하려면 pg_hba.conf 옵션 필드에서 <literal>map</literal>=<replaceable>map-name</replaceable>을 지정해야 한다.
이 옵션은 외부 사용자 이름을 수신하는 모든 인증 방법에서 지원된다.
서로 다른 연결에 서로 다른 매핑이 필요할 수 있으므로 연결별로 사용할 맵을 지정하기 위해 사용할 맵의 이름은 <filename>pg_hba.conf</filename>의 <replaceable>map-name</replaceable> 매개 변수에서 지정된다.
</para>
<para>
사용자 이름 맵은 ident 맵 파일에서 정의되며, 기본적으로 이름은 <filename>pg_ident.conf</filename><indexterm><primary>pg_ident.conf</primary></indexterm>이며 클러스터의 데이터 디렉터리에 저장된다.
(맵 파일을 다른 곳에 배치할 수도 있다. <xref linkend="guc-ident-file"/> 환경 설정 매개 변수를 참조 바란다.)
<synopsis>
<replaceable>map-name</replaceable> <replaceable>system-username</replaceable> <replaceable>database-username</replaceable>
</synopsis>
주석 및 공백은 <filename>pg_hba.conf</filename>에서와 동일하게 처리된다. <replaceable>map-name</replaceable>은 <filename>pg_hba.conf</filename>에서 이 매핑을 참고하기 위해 사용되는 임의의 이름이다.
나머지 2개의 필드는 운영 체제 사용자 이름 및 일치하는 데이터베이스 사용자 이름을 지정한다.
동일한 <replaceable>map-name</replaceable>을 여러 번 사용해서 단일 맵 내에서 복수의 사용자 매핑을 지정할 수 있다.
</para>
<para>
주어진 한 명의 운영 체제 사용자가 몇 명의 데이터베이스 사용자에 대응하는지에 대해서는 아무런 제한이 없다(그 반대로 마찬가지).
따라서, 맵의 항목은 사용자가 동일함을 의미한다기보다 <quote>이 운영 체제 사용자는 이 데이터베이스 사용자로서 연결이 허용된다</quote>로 생각되어야 한다.
사용자가 연결 요청을 한 데이터베이스 사용자 이름을 사용하여 외부 인증 시스템에서 획득한 사용자 이름과 쌍을 이루는 맵 항목이 있을 경우 연결이 허용된다.
</para>
<para>
<replaceable>system-username</replaceable> 필드가 슬래시(<literal>/</literal>)로 시작되는 경우 필드의 나머지는 정규식으로 처리된다. (<productname>PostgreSQL</productname>의 정규식 구문에 대한 내용은 <xref linkend="posix-syntax-details"/>을 참조 바란다.)
정규식은 단일 캡처 또는 괄호 표현식을 포함할 수 있으며, <literal>\1</literal> (역슬래시 1개)로 <replaceable>database-username</replaceable> 필드에서 참조가 가능하다. 이것은 한 줄로 된 복수의 사용자 이름을 매핑할 수 있으며, 단순 구문 대체 시 특히 유용하다.
예를 들면,
<programlisting>
mymap /^(.*)@mydomain\.com$ \1
mymap /^(.*)@otherdomain\.com$ guest
</programlisting>
이 항목은 <literal>@mydomain.com</literal>로 끝나는 시스템 사용자 이름을 사용하여 사용자에 대한 도메인 부분을 삭제하고, 시스템 이름이 <literal>@otherdomain.com</literal>로 끝나는 모든 사용자가 <literal>guest</literal>로 로그인하는 것을 허용한다.
</para>
<tip>
<para>
기본적으로 정규식은 string의 일부만 일치할 수 있다는 점에 유의해야 한다. 위의 예시처럼 전체 시스템 사용자 이름에 일치되도록 강제하려면 <literal>^</literal> 및 <literal>$</literal>를 사용하는 것이 현명하다.
</para>
</tip>
<para>
<filename>pg_ident.conf</filename> 파일은 시작 시 및 메인 서버 프로세스가 <systemitem>SIGHUP</systemitem><indexterm><primary>SIGHUP</primary></indexterm> 신호를 수신하면 읽어지게 된다.
활성 중인 시스템에서 파일을 편집하는 경우 파일을 다시 읽어오려면 postmaster에 신호를 전송해야 한다
(<literal>pg_ctl reload</literal> 또는 <function>pg_reload_conf()</function>
SQL 함수 호출 또는 <literal>kill -HUP</literal> 사용).
</para>
<para>
<xref
linkend="example-pg-hba.conf"/>에서 <filename>pg_ident.conf</filename> 파일과 함께 사용할 수 있는 <filename>pg_hba.conf</filename> 파일이 <xref
linkend="example-pg-ident.conf"/>에 나와 있다. 이 예제에서 운영 체제 사용자 이름 <literal>bryanh</literal> 또는 <literal>ann</literal>, <literal>robert</literal>가 없는 192.168 네트워크에서 머신에 로그인한 사용자는 액세스 권한을 부여 받지 못한다.
Unix 사용자 <literal>robert</literal>는 <literal>robert</literal> 또는 다른 사람이 아니라 <productname>PostgreSQL</productname> 사용자인 <literal>bob</literal>으로 연결을 시도하는 경우에만 액세스가 허용된다.
<literal>ann</literal>은 <literal>ann</literal>으로 연결할 때만 허용된다. 사용자 <literal>bryanh</literal>은 <literal>bryanh</literal> 또는 <literal>guest1</literal>일 때만 연결이 허용된다.
</para>
<example id="example-pg-ident.conf">
<title><filename>pg_ident.conf</filename> 파일 예시</title>
<programlisting>
# MAPNAME SYSTEM-USERNAME PG-USERNAME
omicron bryanh bryanh
omicron ann ann
# bob has user name robert on these machines
omicron robert bob
# bryanh can also connect as guest1
omicron bryanh guest1
</programlisting>
</example>
</sect1>
<sect1 id="auth-methods">
<title>인증 방법</title>
<para>
<productname>PostgreSQL</productname> 다음과 같은 다양한
사용자 인증 방법을 제공한다:
<itemizedlist>
<listitem>
<para>
<link linkend="auth-trust">Trust authentication</link>, which
simply trusts that users are who they say they are.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-password">Password authentication</link>, which
requires that users send a password.
</para>
</listitem>
<listitem>
<para>
<link linkend="gssapi-auth">GSSAPI authentication</link>, which
relies on a GSSAPI-compatible security library. Typically this is
used to access an authentication server such as a Kerberos or
Microsoft Active Directory server.
</para>
</listitem>
<listitem>
<para>
<link linkend="sspi-auth">SSPI authentication</link>, which
uses a Windows-specific protocol similar to GSSAPI.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-ident">Ident authentication</link>, which
relies on an <quote>Identification Protocol</quote> (RFC 1413)
service on the client's machine. (On local Unix-socket connections,
this is treated as peer authentication.)
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-peer">Peer authentication</link>, which
relies on operating system facilities to identify the process at the
other end of a local connection. This is not supported for remote
connections.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-ldap">LDAP authentication</link>, which
relies on an LDAP authentication server.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-radius">RADIUS authentication</link>, which
relies on a RADIUS authentication server.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-cert">Certificate authentication</link>, which
requires an SSL connection and authenticates users by checking the
SSL certificate they send.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-pam">PAM authentication</link>, which
relies on a PAM (Pluggable Authentication Modules) library.
</para>
</listitem>
<listitem>
<para>
<link linkend="auth-bsd">BSD authentication</link>, which
relies on the BSD Authentication framework (currently available
only on OpenBSD).
</para>
</listitem>
</itemizedlist>
</para>
<para>
Peer authentication is usually recommendable for local connections,
though trust authentication might be sufficient in some circumstances.
Password authentication is the easiest choice for remote connections.
All the other options require some kind of external security
infrastructure (usually an authentication server or a certificate
authority for issuing SSL certificates), or are platform-specific.
</para>
<para>
인증 방법은 다음 장부터 자세히 다룬다.
</para>
</sect1>
<sect1 id="auth-trust">
<title>트러스트 인증</title>
<para>
<literal>trust</literal> 인증이 지정된 경우 <productname>PostgreSQL</productname>는 지정한 데이터베이스 사용자 이름을 사용하여 서버에 연결 가능한 모든 이가 데이터베이스 액세스에 대한 인증을 받는 것으로 간주한다(수퍼유저 이름 포함).
물론, <literal>database</literal> 및 <literal>user</literal> 컬럼의 제한도 계속 적용된다.
이 방법은 서버 연결에 대한 적절한 운영 체제 수준의 보호가 제공되는 경우에만 사용되어야 한다.
</para>
<para>
<literal>trust</literal> 인증은 단일 사용자 워크스테이션에 대한 로컬 연결 시 적절하며, 매우 편리하다. 다중 사용자 머신에서는 일반적으로 적절하지 <emphasis>않다</emphasis>.
그러나, 파일 시스템 권한을 사용하여 서버의 Unix 도메인 소켓 파일에 대한 액세스를 제한하는 경우 다중 사용자 머신에서도 <literal>trust</literal>를 사용 가능할 수 있다.
이렇게 하려면 <varname>unix_socket_permissions</varname>(및 가능하면 <varname>unix_socket_group</varname>) 환경 설정 매개 변수를 <xref linkend="runtime-config-connection"/>에서 설명한 대로 설정해야 한다.
또는 <varname>unix_socket_directories</varname> 환경 설정 매개 변수를 설정하여 소켓 파일을 적절히 제한된 디렉터리에 배치할 수 있다.
</para>
<para>
파일 시스템 권한 설정은 Unix 소켓 연결 시에만 유용하다. 로컬 TCP/IP 연결은 파일 시스템 권한에 의해 제한되지 않는다.
따라서 로컬 보안을 위해 파일 시스템 권한을 사용하려면 <literal>host ... 127.0.0.1 ...</literal> 줄을 <filename>pg_hba.conf</filename>에서 삭제하거나, 비 <literal>trust</literal> 방법으로 변경해야 한다.
</para>
<para>
<literal>trust</literal> 인증은 <literal>trust</literal>를 지정하는 <filename>pg_hba.conf</filename> 줄에 의해 서버로의 연결이 허용된 모든 머신의 모든 사용자를 신뢰하는 경우에 TCP/IP 연결에 대해서만 적합하다.
<systemitem>localhost</systemitem>(127.0.0.1) 외에 TCP/IP 연결에 대해 <literal>trust</literal>를 사용하는 것은 별로 합당하지 않다.
</para>
</sect1>
<sect1 id="auth-password">
<title>패스워드 인증</title>
<indexterm>
<primary>MD5</primary>
</indexterm>
<indexterm>
<primary>SCRAM</primary>
</indexterm>
<indexterm>
<primary>패스워드</primary>
<secondary>인증</secondary>
</indexterm>
<para>
There are several password-based authentication methods. These methods
operate similarly but differ in how the users' passwords are stored on the
server and how the password provided by a client is sent across the
connection.
</para>
<variablelist>
<varlistentry>
<term><literal>scram-sha-256</literal></term>
<listitem>
<para>
The method <literal>scram-sha-256</literal> performs SCRAM-SHA-256
authentication, as described in
<ulink url="https://tools.ietf.org/html/rfc7677">RFC 7677</ulink>. It
is a challenge-response scheme that prevents password sniffing on
untrusted connections and supports storing passwords on the server in a
cryptographically hashed form that is thought to be secure.
</para>
<para>
This is the most secure of the currently provided methods, but it is
not supported by older client libraries.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>md5</literal></term>
<listitem>
<para>
The method <literal>md5</literal> uses a custom less secure challenge-response
mechanism. It prevents password sniffing and avoids storing passwords
on the server in plain text but provides no protection if an attacker
manages to steal the password hash from the server. Also, the MD5 hash
algorithm is nowadays no longer considered secure against determined
attacks.
</para>
<para>
The <literal>md5</literal> method cannot be used with
the <xref linkend="guc-db-user-namespace"/> feature.
</para>
<para>
To ease transition from the <literal>md5</literal> method to the newer
SCRAM method, if <literal>md5</literal> is specified as a method
in <filename>pg_hba.conf</filename> but the user's password on the
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>password</literal></term>
<listitem>
<para>
The method <literal>password</literal> sends the password in clear-text and is
therefore vulnerable to password <quote>sniffing</quote> attacks. It should
always be avoided if possible. If the connection is protected by SSL
encryption then <literal>password</literal> can be used safely, though.
(Though SSL certificate authentication might be a better choice if one
is depending on using SSL).
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
<productname>PostgreSQL</productname> 데이터베이스 패스워드는 운영 체제 사용자 패스워드와
구분된다. 각 데이터베이스 사용자에 대한 패스워드는 <literal>pg_authid</literal>
시스템 카탈로그에 저장된다. 패스워드는 SQL 명령 <xref linkend="sql-createrole"/>
및 <xref linkend="sql-alterrole"/>으로 관리할 수 있으며, 예를
들면 <userinput>CREATE ROLE foo WITH LOGIN PASSWORD 'secret'</userinput>,
또는 <application>psql</application> 내장 명령어
<literal>\password</literal> 같은 작업으로 처리한다. 패스워드가 사용자에 대해 설정되지 않은
경우 저장된 패스워드는 null이고 패스워드 인증은 해당 사용자에 대해 항상 실패한다.
</para>
<para>
The availability of the different password-based authentication methods
depends on how a user's password on the server is encrypted (or hashed,
more accurately). This is controlled by the configuration
parameter <xref linkend="guc-password-encryption"/> at the time the
password is set. If a password was encrypted using
the <literal>scram-sha-256</literal> setting, then it can be used for the
authentication methods <literal>scram-sha-256</literal>
and <literal>password</literal> (but password transmission will be in
plain text in the latter case). The authentication method
specification <literal>md5</literal> will automatically switch to using
the <literal>scram-sha-256</literal> method in this case, as explained
above, so it will also work. If a password was encrypted using
the <literal>md5</literal> setting, then it can be used only for
the <literal>md5</literal> and <literal>password</literal> authentication
method specifications (again, with the password transmitted in plain text
in the latter case). (Previous PostgreSQL releases supported storing the
password on the server in plain text. This is no longer possible.) To
check the currently stored password hashes, see the system
catalog <literal>pg_authid</literal>.
</para>
<para>
To upgrade an existing installation from <literal>md5</literal>
to <literal>scram-sha-256</literal>, after having ensured that all client
libraries in use are new enough to support SCRAM,
set <literal>password_encryption = 'scram-sha-256'</literal>
in <filename>postgresql.conf</filename>, make all users set new passwords,
and change the authentication method specifications
in <filename>pg_hba.conf</filename> to <literal>scram-sha-256</literal>.
</para>
</sect1>
<sect1 id="gssapi-auth">
<title>GSSAPI 인증</title>
<indexterm zone="gssapi-auth">
<primary>GSSAPI</primary>
</indexterm>
<para>
<productname>GSSAPI</productname> is an industry-standard protocol
for secure authentication defined in
<ulink url="https://tools.ietf.org/html/rfc2743">RFC 2743</ulink>.
<productname>PostgreSQL</productname>
supports <productname>GSSAPI</productname> for authentication,
communications encryption, or both.
<productname>GSSAPI</productname> provides automatic authentication
(single sign-on) for systems that support it. The authentication itself is
secure. If <productname>GSSAPI</productname> encryption
or <acronym>SSL</acronym> encryption is
used, the data sent along the database connection will be encrypted;
otherwise, it will not.
</para>
<para>
GSSAPI는 PostgreSQL이 빌드된 경우 활성화되어야 한다. 자세한
내용은 <xref linkend="installation"/>을 참조 바란다.
</para>
<para>
When <productname>GSSAPI</productname> uses
<productname>Kerberos</productname>, it uses a standard service
principal (authentication identity) name in the format
<literal><replaceable>servicename</replaceable>/<replaceable>hostname</replaceable>@<replaceable>realm</replaceable></literal>.
The principal name used by a particular installation is not encoded in
the <productname>PostgreSQL</productname> server in any way; rather it
is specified in the <firstterm>keytab</firstterm> file that the server
reads to determine its identity. If multiple principals are listed in
the keytab file, the server will accept any one of them.
The server's realm name is the preferred realm specified in the Kerberos
configuration file(s) accessible to the server.
</para>
<para>
When connecting, the client must know the principal name of the server
it intends to connect to. The <replaceable>servicename</replaceable>
part of the principal is ordinarily <literal>postgres</literal>,