~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/role-attributes.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>Role Attributes</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REV="MADE"
 
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
 
11
REL="HOME"
 
12
TITLE="PostgreSQL 9.1beta1 Documentation"
 
13
HREF="index.html"><LINK
 
14
REL="UP"
 
15
TITLE="Database Roles"
 
16
HREF="user-manag.html"><LINK
 
17
REL="PREVIOUS"
 
18
TITLE="Database Roles"
 
19
HREF="database-roles.html"><LINK
 
20
REL="NEXT"
 
21
TITLE="Role Membership"
 
22
HREF="role-membership.html"><LINK
 
23
REL="STYLESHEET"
 
24
TYPE="text/css"
 
25
HREF="stylesheet.css"><META
 
26
HTTP-EQUIV="Content-Type"
 
27
CONTENT="text/html; charset=ISO-8859-1"><META
 
28
NAME="creation"
 
29
CONTENT="2011-04-27T21:20:33"></HEAD
 
30
><BODY
 
31
CLASS="SECT1"
 
32
><DIV
 
33
CLASS="NAVHEADER"
 
34
><TABLE
 
35
SUMMARY="Header navigation table"
 
36
WIDTH="100%"
 
37
BORDER="0"
 
38
CELLPADDING="0"
 
39
CELLSPACING="0"
 
40
><TR
 
41
><TH
 
42
COLSPAN="5"
 
43
ALIGN="center"
 
44
VALIGN="bottom"
 
45
><A
 
46
HREF="index.html"
 
47
>PostgreSQL 9.1beta1 Documentation</A
 
48
></TH
 
49
></TR
 
50
><TR
 
51
><TD
 
52
WIDTH="10%"
 
53
ALIGN="left"
 
54
VALIGN="top"
 
55
><A
 
56
TITLE="Database Roles"
 
57
HREF="database-roles.html"
 
58
ACCESSKEY="P"
 
59
>Prev</A
 
60
></TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="left"
 
64
VALIGN="top"
 
65
><A
 
66
TITLE="Database Roles"
 
67
HREF="user-manag.html"
 
68
>Fast Backward</A
 
69
></TD
 
70
><TD
 
71
WIDTH="60%"
 
72
ALIGN="center"
 
73
VALIGN="bottom"
 
74
>Chapter 20. Database Roles</TD
 
75
><TD
 
76
WIDTH="10%"
 
77
ALIGN="right"
 
78
VALIGN="top"
 
79
><A
 
80
TITLE="Database Roles"
 
81
HREF="user-manag.html"
 
82
>Fast Forward</A
 
83
></TD
 
84
><TD
 
85
WIDTH="10%"
 
86
ALIGN="right"
 
87
VALIGN="top"
 
88
><A
 
89
TITLE="Role Membership"
 
90
HREF="role-membership.html"
 
91
ACCESSKEY="N"
 
92
>Next</A
 
93
></TD
 
94
></TR
 
95
></TABLE
 
96
><HR
 
97
ALIGN="LEFT"
 
98
WIDTH="100%"></DIV
 
99
><DIV
 
100
CLASS="SECT1"
 
101
><H1
 
102
CLASS="SECT1"
 
103
><A
 
104
NAME="ROLE-ATTRIBUTES"
 
105
>20.2. Role Attributes</A
 
106
></H1
 
107
><P
 
108
>    A database role can have a number of attributes that define its
 
109
    privileges and interact with the client authentication system.
 
110
 
 
111
    <P
 
112
></P
 
113
></P><DIV
 
114
CLASS="VARIABLELIST"
 
115
><DL
 
116
><DT
 
117
>login privilege</DT
 
118
><DD
 
119
><P
 
120
>        Only roles that have the <TT
 
121
CLASS="LITERAL"
 
122
>LOGIN</TT
 
123
> attribute can be used
 
124
        as the initial role name for a database connection.  A role with
 
125
        the <TT
 
126
CLASS="LITERAL"
 
127
>LOGIN</TT
 
128
> attribute can be considered the same
 
129
        as a <SPAN
 
130
CLASS="QUOTE"
 
131
>"database user"</SPAN
 
132
>.  To create a role with login privilege,
 
133
        use either:
 
134
</P><PRE
 
135
CLASS="PROGRAMLISTING"
 
136
>CREATE ROLE <TT
 
137
CLASS="REPLACEABLE"
 
138
><I
 
139
>name</I
 
140
></TT
 
141
> LOGIN;
 
142
CREATE USER <TT
 
143
CLASS="REPLACEABLE"
 
144
><I
 
145
>name</I
 
146
></TT
 
147
>;</PRE
 
148
><P>
 
149
        (<TT
 
150
CLASS="COMMAND"
 
151
>CREATE USER</TT
 
152
> is equivalent to <TT
 
153
CLASS="COMMAND"
 
154
>CREATE ROLE</TT
 
155
>
 
156
        except that <TT
 
157
CLASS="COMMAND"
 
158
>CREATE USER</TT
 
159
> assumes <TT
 
160
CLASS="LITERAL"
 
161
>LOGIN</TT
 
162
> by
 
163
        default, while <TT
 
164
CLASS="COMMAND"
 
165
>CREATE ROLE</TT
 
166
> does not.)
 
167
       </P
 
168
></DD
 
169
><DT
 
170
>superuser status</DT
 
171
><DD
 
172
><P
 
173
>        A database superuser bypasses all permission checks, except the right
 
174
        to log in or the right to initiate replication.  This is a
 
175
        dangerous privilege and should not be used carelessly; it is best
 
176
        to do most of your work as a role that is not a superuser.
 
177
        To create a new database superuser, use <TT
 
178
CLASS="LITERAL"
 
179
>CREATE ROLE
 
180
        <TT
 
181
CLASS="REPLACEABLE"
 
182
><I
 
183
>name</I
 
184
></TT
 
185
> SUPERUSER</TT
 
186
>.  You must do
 
187
        this as a role that is already a superuser. Creating a superuser
 
188
        will by default also grant permissions to initiate streaming
 
189
        replication. For increased security this can be disallowed using
 
190
        <TT
 
191
CLASS="LITERAL"
 
192
>CREATE ROLE <TT
 
193
CLASS="REPLACEABLE"
 
194
><I
 
195
>name</I
 
196
></TT
 
197
> SUPERUSER
 
198
        NOREPLICATION</TT
 
199
>.
 
200
       </P
 
201
></DD
 
202
><DT
 
203
>database creation</DT
 
204
><DD
 
205
><P
 
206
>        A role must be explicitly given permission to create databases
 
207
        (except for superusers, since those bypass all permission
 
208
        checks). To create such a role, use <TT
 
209
CLASS="LITERAL"
 
210
>CREATE ROLE
 
211
        <TT
 
212
CLASS="REPLACEABLE"
 
213
><I
 
214
>name</I
 
215
></TT
 
216
> CREATEDB</TT
 
217
>.
 
218
       </P
 
219
></DD
 
220
><DT
 
221
>role creation</DT
 
222
><DD
 
223
><P
 
224
>        A role must be explicitly given permission to create more roles
 
225
        (except for superusers, since those bypass all permission
 
226
        checks). To create such a role, use <TT
 
227
CLASS="LITERAL"
 
228
>CREATE ROLE
 
229
        <TT
 
230
CLASS="REPLACEABLE"
 
231
><I
 
232
>name</I
 
233
></TT
 
234
> CREATEROLE</TT
 
235
>.
 
236
        A role with <TT
 
237
CLASS="LITERAL"
 
238
>CREATEROLE</TT
 
239
> privilege can alter and drop
 
240
        other roles, too, as well as grant or revoke membership in them.
 
241
        However, to create, alter, drop, or change membership of a
 
242
        superuser role, superuser status is required;
 
243
        <TT
 
244
CLASS="LITERAL"
 
245
>CREATEROLE</TT
 
246
> is insufficient for that.
 
247
       </P
 
248
></DD
 
249
><DT
 
250
>initiating replication</DT
 
251
><DD
 
252
><P
 
253
>        A role must explicitly be given permission to initiate streaming
 
254
        replication. A role used for streaming replication must always
 
255
        have <TT
 
256
CLASS="LITERAL"
 
257
>LOGIN</TT
 
258
> permission as well. To create such a role, use
 
259
        <TT
 
260
CLASS="LITERAL"
 
261
>CREATE ROLE <TT
 
262
CLASS="REPLACEABLE"
 
263
><I
 
264
>name</I
 
265
></TT
 
266
> REPLICATION
 
267
        LOGIN</TT
 
268
>.
 
269
       </P
 
270
></DD
 
271
><DT
 
272
>password</DT
 
273
><DD
 
274
><P
 
275
>        A password is only significant if the client authentication
 
276
        method requires the user to supply a password when connecting
 
277
        to the database. The <TT
 
278
CLASS="OPTION"
 
279
>password</TT
 
280
> and
 
281
        <TT
 
282
CLASS="OPTION"
 
283
>md5</TT
 
284
> authentication methods
 
285
        make use of passwords. Database passwords are separate from
 
286
        operating system passwords. Specify a password upon role
 
287
        creation with <TT
 
288
CLASS="LITERAL"
 
289
>CREATE ROLE
 
290
        <TT
 
291
CLASS="REPLACEABLE"
 
292
><I
 
293
>name</I
 
294
></TT
 
295
> PASSWORD '<TT
 
296
CLASS="REPLACEABLE"
 
297
><I
 
298
>string</I
 
299
></TT
 
300
>'</TT
 
301
>.
 
302
       </P
 
303
></DD
 
304
></DL
 
305
></DIV
 
306
><P>
 
307
 
 
308
    A role's attributes can be modified after creation with
 
309
    <TT
 
310
CLASS="COMMAND"
 
311
>ALTER ROLE</TT
 
312
>.
 
313
    See the reference pages for the <A
 
314
HREF="sql-createrole.html"
 
315
>CREATE ROLE</A
 
316
> and <A
 
317
HREF="sql-alterrole.html"
 
318
>ALTER ROLE</A
 
319
> commands for details.
 
320
   </P
 
321
><DIV
 
322
CLASS="TIP"
 
323
><BLOCKQUOTE
 
324
CLASS="TIP"
 
325
><P
 
326
><B
 
327
>Tip: </B
 
328
>    It is good practice to create a role that has the <TT
 
329
CLASS="LITERAL"
 
330
>CREATEDB</TT
 
331
>
 
332
    and <TT
 
333
CLASS="LITERAL"
 
334
>CREATEROLE</TT
 
335
> privileges, but is not a superuser, and then
 
336
    use this role for all routine management of databases and roles.  This
 
337
    approach avoids the dangers of operating as a superuser for tasks that
 
338
    do not really require it.
 
339
   </P
 
340
></BLOCKQUOTE
 
341
></DIV
 
342
><P
 
343
>   A role can also have role-specific defaults for many of the run-time
 
344
   configuration settings described in <A
 
345
HREF="runtime-config.html"
 
346
>Chapter 18</A
 
347
>.  For example, if for some reason you
 
348
   want to disable index scans (hint: not a good idea) anytime you
 
349
   connect, you can use:
 
350
</P><PRE
 
351
CLASS="PROGRAMLISTING"
 
352
>ALTER ROLE myname SET enable_indexscan TO off;</PRE
 
353
><P>
 
354
   This will save the setting (but not set it immediately).  In
 
355
   subsequent connections by this role it will appear as though
 
356
   <TT
 
357
CLASS="LITERAL"
 
358
>SET enable_indexscan TO off</TT
 
359
> had been executed
 
360
   just before the session started.
 
361
   You can still alter this setting during the session; it will only
 
362
   be the default. To remove a role-specific default setting, use
 
363
   <TT
 
364
CLASS="LITERAL"
 
365
>ALTER ROLE <TT
 
366
CLASS="REPLACEABLE"
 
367
><I
 
368
>rolename</I
 
369
></TT
 
370
> RESET <TT
 
371
CLASS="REPLACEABLE"
 
372
><I
 
373
>varname</I
 
374
></TT
 
375
></TT
 
376
>.
 
377
   Note that role-specific defaults attached to roles without
 
378
   <TT
 
379
CLASS="LITERAL"
 
380
>LOGIN</TT
 
381
> privilege are fairly useless, since they will never
 
382
   be invoked.
 
383
  </P
 
384
></DIV
 
385
><DIV
 
386
CLASS="NAVFOOTER"
 
387
><HR
 
388
ALIGN="LEFT"
 
389
WIDTH="100%"><TABLE
 
390
SUMMARY="Footer navigation table"
 
391
WIDTH="100%"
 
392
BORDER="0"
 
393
CELLPADDING="0"
 
394
CELLSPACING="0"
 
395
><TR
 
396
><TD
 
397
WIDTH="33%"
 
398
ALIGN="left"
 
399
VALIGN="top"
 
400
><A
 
401
HREF="database-roles.html"
 
402
ACCESSKEY="P"
 
403
>Prev</A
 
404
></TD
 
405
><TD
 
406
WIDTH="34%"
 
407
ALIGN="center"
 
408
VALIGN="top"
 
409
><A
 
410
HREF="index.html"
 
411
ACCESSKEY="H"
 
412
>Home</A
 
413
></TD
 
414
><TD
 
415
WIDTH="33%"
 
416
ALIGN="right"
 
417
VALIGN="top"
 
418
><A
 
419
HREF="role-membership.html"
 
420
ACCESSKEY="N"
 
421
>Next</A
 
422
></TD
 
423
></TR
 
424
><TR
 
425
><TD
 
426
WIDTH="33%"
 
427
ALIGN="left"
 
428
VALIGN="top"
 
429
>Database Roles</TD
 
430
><TD
 
431
WIDTH="34%"
 
432
ALIGN="center"
 
433
VALIGN="top"
 
434
><A
 
435
HREF="user-manag.html"
 
436
ACCESSKEY="U"
 
437
>Up</A
 
438
></TD
 
439
><TD
 
440
WIDTH="33%"
 
441
ALIGN="right"
 
442
VALIGN="top"
 
443
>Role Membership</TD
 
444
></TR
 
445
></TABLE
 
446
></DIV
 
447
></BODY
 
448
></HTML
 
449
>
 
 
b'\\ No newline at end of file'