20.6. GSSAPI 인증

GSSAPI는 RFC 2743에 정의된 보안 인증을 위한 산업 표준 프로토콜이다. PostgreSQL은 RFC 1964에 따라 Kerberos를 사용한 GSSAPI를 지원한다. GSSAPI은 이것을 지원하는 시스템에 대해 자동 인증(single sign-on)을 제공한다. 인증 자체는 안전하지만, SSL을 사용하지 않을 경우 데이터베이스 연결을 통해 전송된 데이터는 암호화되지 않은 상태로 전송된다.

GSSAPI는 PostgreSQL이 빌드된 경우 활성화되어야 한다. 자세한 내용은 16장을 참조 바란다.

GSSAPIKerberos를 사용하는 경우 servicename/hostname@realm 형식으로 표준 보안 주체(principal)가 사용된다. PostgreSQL 서버가 서버에서 사용되는 키탭에 포함된 보안 주체(principal)를 수용하지만, krbsrvname 연결 매개 변수를 사용하여 클라이언트에서 연결을 할 때 올바른 보안 주체(principal) 상세 정보를 지정할 때 특별히 주의해야 한다. (34.1.2절도 참조 바란다.) 설치 기본값은 빌드 시에 ./configure --with-krb-srvnam=whatever를 사용하여 기본값 postgres에서 변경 가능하다. 대부분의 환경에서 이 매개 변수는 절대 변경할 필요가 없다. 일부 Kerberos 구현은 서비스 이름이 대문자여야 하는 Microsoft Active Directory처럼 서로 다른 서비스 이름을 요구할 수도 있다(POSTGRES).

hostname은 서버 머신의 정규화된 호스트 이름이다. 서비스 보안 주체의 영역(principal's realm)은 서버 머신의 기본 설정된 영역(realm)이다.

Client principals can be mapped to different PostgreSQL database user names with pg_ident.conf. For example, pgusername@realm could be mapped to just pgusername. Alternatively, you can use the full username@realm principal as the role name in PostgreSQL without any mapping.

PostgreSQL also supports a parameter to strip the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set include_realm to 0. For simple single-realm installations, doing that combined with setting the krb_realm parameter (which checks that the principal's realm matches exactly what is in the krb_realm parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in pg_ident.conf.

사용자는 서버 키탭 파일을 PostgreSQL 서버 계정으로 읽기 가능한지(읽기 가능만, 쓰기 불가) 확인해야 한다. (18.1절도 참조 바란다.) 키 파일의 위치는 krb_server_keyfile 환경 설정 매개 변수에 의해 지정된다. 기본값은 /usr/local/pgsql/etc/krb5.keytab(또는 빌드 시 sysconfdir로 지정된 아무 디렉터리). 보안상의 이유로, 시스템 키탭 파일에 대한 권한을 여는 것보다는 PostgreSQL 서버에 대해 별개의 키탭을 사용하는 것이 바람직하다.

키탭 파일은 Kerberos 소프트웨어에 의해 생성된다. 자세한 내용은 Kerberos 문서를 참조 바란다. 다음 예시는 MIT 호환 Kerberos 5 구현에 대한 것이다.

kadmin% ank -randkey postgres/server.my.domain.org
kadmin% ktadd -k krb5.keytab postgres/server.my.domain.org

데이터베이스에 연결할 때 요청된 데이터베이스 사용자 이름과 일치하는 보안 주체(principal)에 대한 티켓이 있는지 확인해야 한다. 예를 들면, 데이터베이스 이름 fred의 경우 보안 주체(principal) fred@EXAMPLE.COM은 연결이 가능하다. 보안 주체(principal) fred/users.example.com@EXAMPLE.COM의 연결도 허용하려면 20.2절에 설명된 대로 사용자 이름 맵을 사용해야 한다.

다음 환경 설정 옵션이 GSSAPI에 대해 지원된다.

include_realm

If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (20.2절). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names.

map

시스템과 데이터베이스 사용자 이름 사이의 매핑을 허용한다. 자세한 내용은 20.2절을 참조 바란다. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM, respectively), unless include_realm has been set to 0, in which case username (or username/hostbased) is what is seen as the system user name when mapping.

krb_realm

사용자 보안 주체(principal) 이름과 일치하는 영역(realm)을 설정한다. 이 매개 변수가 설정된 경우 해당 영역(realm)의 사용자만 허용된다. 설정되지 않으면 모든 영역(realm)의 사용자가 연결할 수 있으며, 사용자 이름 매핑 완료 여부에 달려 있다.