1 access control. 2 grant statement 3 access control grant statement grant statement may be used by...

49
1 Access control

Upload: ambrose-logan

Post on 18-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

1

Access controlAccess control

Page 2: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

2

Access controlAccess control

• GRANT statement• GRANT statement

Page 3: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

3

Access controlAccess control

• GRANT statement

GRANT statement may be used by

a user to authorise various kinds

of access to his/her tables by another

user or class of users

• GRANT statement

GRANT statement may be used by

a user to authorise various kinds

of access to his/her tables by another

user or class of users

Page 4: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

4

Access controlAccess control

• Syntax

GRANT

• Syntax

GRANT ALL<list of privileges>

Page 5: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

5

Access controlAccess control

• Syntax

GRANT ON

• Syntax

GRANT ONALL<list of privileges>

<table name><view name>

Page 6: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

6

Access controlAccess control

• Syntax

GRANT ON

TO

• Syntax

GRANT ON

TO

ALL<list of privileges>

<table name><view name>

PUBLIC<list of users>

Page 7: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

7

Access controlAccess control

• Syntax

GRANT ON

TO [WITH GRANT OPTION];

• Syntax

GRANT ON

TO [WITH GRANT OPTION];

ALL<list of privileges>

<table name><view name>

PUBLIC<list of users>

Page 8: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

8

Access controlAccess control

• Privileges• Privileges

Page 9: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

9

Access controlAccess control

• Privileges

SELECTGrantee is allowed to select data from a table determined by a grantor

• Privileges

SELECTGrantee is allowed to select data from a table determined by a grantor

Page 10: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

10

Access controlAccess control

• Privileges

SELECTGrantee is allowed to selected data from a table determined by a grantor

DELETEGrantee is allowed to delete data from a table determined by a grantor

• Privileges

SELECTGrantee is allowed to selected data from a table determined by a grantor

DELETEGrantee is allowed to delete data from a table determined by a grantor

Page 11: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

11

Access controlAccess control

• Privileges

SELECTGrantee is allowed to selected data from a table determined by a grantor

DELETEGrantee is allowed to delete data from a table determined by a grantor

INSERTGrantee is allowed to insert data into a table determined by a grantor

• Privileges

SELECTGrantee is allowed to selected data from a table determined by a grantor

DELETEGrantee is allowed to delete data from a table determined by a grantor

INSERTGrantee is allowed to insert data into a table determined by a grantor

Page 12: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

12

Access controlAccess control

• Privileges

SELECTGrantee is allowed to selected data from a table determined by a grantor

DELETEGrantee is allowed to delete data from a table determined by a grantor

INSERTGrantee is allowed to insert data into a table determined by a grantor

• Privileges

SELECTGrantee is allowed to selected data from a table determined by a grantor

DELETEGrantee is allowed to delete data from a table determined by a grantor

INSERTGrantee is allowed to insert data into a table determined by a grantor

Page 13: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

13

Access controlAccess control

• Privileges

UPDATE [<list of columns>]Grantee is allowed to update the columns from a table determined by a grantor

• Privileges

UPDATE [<list of columns>]Grantee is allowed to update the columns from a table determined by a grantor

Page 14: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

14

Access controlAccess control

• Privileges

UPDATE [<list of columns>]Grantee is allowed to update the columns from a table determined by a grantor

REFERENCES [<list of columns]Grantee is allowed to reference the columns from a table specified by a grantor

• Privileges

UPDATE [<list of columns>]Grantee is allowed to update the columns from a table determined by a grantor

REFERENCES [<list of columns]Grantee is allowed to reference the columns from a table specified by a grantor

Page 15: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

15

Access controlAccess control

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

Page 16: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

16

Access controlAccess control

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

privilege

Page 17: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

17

Access controlAccess control

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

privilege

table (view) name

Page 18: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

18

Access controlAccess control

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

privilege

table (view) name

user

Page 19: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

19

Access controlAccess control

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

Then user Janusz can say: SELECT * FROM Scott.Supplier;

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

Then user Janusz can say: SELECT * FROM Scott.Supplier;

Page 20: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

20

Access controlAccess control

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

Then user Janusz can say: SELECT * FROM Scott.Supplier;

• Granting privileges

User Scott says:GRANT SELECT ON Supplier TO Janusz;

Then user Janusz can say: SELECT * FROM Scott.Supplier;

user.table

Page 21: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

21

Access controlAccess control

• Granting privileges

User Janusz says:CREATE SYNONYM Ssupplier

FOR Scott.Supplier;

• Granting privileges

User Janusz says:CREATE SYNONYM Ssupplier

FOR Scott.Supplier;

Page 22: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

22

Access controlAccess control

• Granting privileges

User Janusz says:CREATE SYNONYM Ssupplier

FOR Scott.Supplier;

Then user Janusz can say:SELECT * FROM Ssupplier;

• Granting privileges

User Janusz says:CREATE SYNONYM Ssupplier

FOR Scott.Supplier;

Then user Janusz can say:SELECT * FROM Ssupplier;

Page 23: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

23

Access controlAccess control

• Granting privileges

User Scott says:GRANT UPDATE pname, price ON Part

TO Janusz;

• Granting privileges

User Scott says:GRANT UPDATE pname, price ON Part

TO Janusz;

Page 24: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

24

Access controlAccess control

• Granting privileges

User Scott says:GRANT UPDATE pname, price ON Part

TO Janusz;

Then user Janusz can say:UPDATE Scott.Part SET price = price + 10

WHERE pname =‘bolt’;

• Granting privileges

User Scott says:GRANT UPDATE pname, price ON Part

TO Janusz;

Then user Janusz can say:UPDATE Scott.Part SET price = price + 10

WHERE pname =‘bolt’;

Page 25: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

25

Access controlAccess control

• Granting privileges

User Scott says:GRANT ALL ON Supplier TO PUBLIC;

• Granting privileges

User Scott says:GRANT ALL ON Supplier TO PUBLIC;

Page 26: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

26

Access controlAccess control

• Granting privileges

User Scott says:GRANT ALL ON Supplier TO PUBLIC;

Then anyone can say:SELECT * FROM Scott.Supplier;

UPDATE Scott.Part SET price = price + 10

WHERE pname =‘bolt’;

INSERT INTO Scott.Supplier VALUES( ... );

DELETE FROM Scott.Supplier;

• Granting privileges

User Scott says:GRANT ALL ON Supplier TO PUBLIC;

Then anyone can say:SELECT * FROM Scott.Supplier;

UPDATE Scott.Part SET price = price + 10

WHERE pname =‘bolt’;

INSERT INTO Scott.Supplier VALUES( ... );

DELETE FROM Scott.Supplier;

Page 27: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

27

Access controlAccess control

• Granting privileges

User Scott says:GRANT REFERENCE s# ON Supplier

TO Janusz;

• Granting privileges

User Scott says:GRANT REFERENCE s# ON Supplier

TO Janusz;

Page 28: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

28

Access controlAccess control

• Granting privileges

User Scott says:GRANT REFERENCE s# ON Supplier

TO Janusz;

Then user Janusz can say:CREATE TABLE MySP( s# …

CONSTRAINT MySP_fkey FOREIGN KEY(s#) REFERENCES Scott.SP(s#);

• Granting privileges

User Scott says:GRANT REFERENCE s# ON Supplier

TO Janusz;

Then user Janusz can say:CREATE TABLE MySP( s# …

CONSTRAINT MySP_fkey FOREIGN KEY(s#) REFERENCES Scott.SP(s#);

Page 29: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

29

Access controlAccess control

• Granting privileges

User Scott says:GRANT REFERENCE s# ON Supplier

TO Janusz;

Then user Janusz can say:CREATE TABLE MySP( s# …

CONSTRAINT MySP_fkey FOREIGN KEY(s#) REFERENCES Scott.SP(s#);

• Granting privileges

User Scott says:GRANT REFERENCE s# ON Supplier

TO Janusz;

Then user Janusz can say:CREATE TABLE MySP( s# …

CONSTRAINT MySP_fkey FOREIGN KEY(s#) REFERENCES Scott.SP(s#);

Page 30: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

30

Access controlAccess control

• Granting privileges

User Scott says:CREATE VIEW SuppliersFrom London AS

SELECT *

FROM Supplier

WHERE city = ‘London;

• Granting privileges

User Scott says:CREATE VIEW SuppliersFrom London AS

SELECT *

FROM Supplier

WHERE city = ‘London;

Page 31: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

31

Access controlAccess control

• Granting privileges

User Scott says:CREATE VIEW SuppliersFromLondon AS

SELECT *

FROM Supplier

WHERE city = ‘London;

GRANT DELETE ON SuppliersFromLondon TO Janusz;

• Granting privileges

User Scott says:CREATE VIEW SuppliersFromLondon AS

SELECT *

FROM Supplier

WHERE city = ‘London;

GRANT DELETE ON SuppliersFromLondon TO Janusz;

Page 32: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

32

Access controlAccess control

• Granting privileges

Then user Janusz can say:DELETE FROM Scott.SuppliersFromLondon

WHERE dob < ‘1-JAN-38’;

• Granting privileges

Then user Janusz can say:DELETE FROM Scott.SuppliersFromLondon

WHERE dob < ‘1-JAN-38’;

Page 33: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

33

Access controlAccess control

• Granting privileges

User Scott says:CREATE VIEW PartShort AS

SELECT p#, pname

FROM Part;

• Granting privileges

User Scott says:CREATE VIEW PartShort AS

SELECT p#, pname

FROM Part;

Page 34: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

34

Access controlAccess control

• Granting privileges

User Scott says:CREATE VIEW PartShort AS

SELECT p#, pname

FROM Part;

GRANT SELECT ON PartShort TO Janusz;

• Granting privileges

User Scott says:CREATE VIEW PartShort AS

SELECT p#, pname

FROM Part;

GRANT SELECT ON PartShort TO Janusz;

Page 35: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

35

Access controlAccess control

• Granting privileges

Then user Janusz can say:SELECT p#

FROM Scott.PartShort

WHERE pname = ‘bolt’;

• Granting privileges

Then user Janusz can say:SELECT p#

FROM Scott.PartShort

WHERE pname = ‘bolt’;

Page 36: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

36

Access controlAccess control

• Grant propagation• Grant propagation

Page 37: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

37

Access controlAccess control

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

Page 38: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

38

Access controlAccess control

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

WITH GRANT OPTION;

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

WITH GRANT OPTION;

Page 39: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

39

Access controlAccess control

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

WITH GRANT OPTION;

Then user JK02 says:CREATE VIEW SPShort AS

SELECT s#, p#

FROM SP;

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

WITH GRANT OPTION;

Then user JK02 says:CREATE VIEW SPShort AS

SELECT s#, p#

FROM SP;

Page 40: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

40

Access controlAccess control

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

WITH GRANT OPTION;

Then user JK02 says:CREATE VIEW SPShort AS

SELECT s#, p#

FROM SP;

GRANT SELECT ON SPShort TO Janusz;

• Grant propagation

User Scott says:GRANT SELECT ON SP TO JK02

WITH GRANT OPTION;

Then user JK02 says:CREATE VIEW SPShort AS

SELECT s#, p#

FROM SP;

GRANT SELECT ON SPShort TO Janusz;

Page 41: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

41

Access controlAccess control

• Grant propagation

Then user Janusz can say:SELECT *

FROM JK02.SPShort;

• Grant propagation

Then user Janusz can say:SELECT *

FROM JK02.SPShort;

Page 42: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

42

Access controlAccess control

• Grant propagation

Then user Janusz can say:SELECT *

FROM JK02.SPShort;

User Janusz can’t say:GRANT SELECT ON SPShort TO Greg;

• Grant propagation

Then user Janusz can say:SELECT *

FROM JK02.SPShort;

User Janusz can’t say:GRANT SELECT ON SPShort TO Greg;

Page 43: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

43

Access controlAccess control

• REVOKE statement• REVOKE statement

Page 44: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

44

Access controlAccess control

• REVOKE statement

REVOKE statement may be used to revoke

a subset privileges granted to a user

• REVOKE statement

REVOKE statement may be used to revoke

a subset privileges granted to a user

Page 45: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

45

Access controlAccess control

• Syntax

REVOKE ON

FROM ;

• Syntax

REVOKE ON

FROM ;

ALL<list of privileges>

<table name><view name>

PUBLIC<list of users>

Page 46: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

46

Access controlAccess control

• Revoking privileges

User Scott says:REVOKE SELECT ON SP FROM JK02 ;

• Revoking privileges

User Scott says:REVOKE SELECT ON SP FROM JK02 ;

Page 47: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

47

Access controlAccess control

• Revoking privileges

User Scott says:REVOKE SELECT ON SP FROM JK02 ;

Then user JK02 can’t say:SELECT * FROM Scott.SP;

• Revoking privileges

User Scott says:REVOKE SELECT ON SP FROM JK02 ;

Then user JK02 can’t say:SELECT * FROM Scott.SP;

Page 48: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

48

Access controlAccess control

• Revoking privileges

User Scott says:REVOKE SELECT ON SP FROM JK02 ;

Then user JK02 can’t say:SELECT * FROM Scott.SP;

and user Janusz can’t say:SELECT * FROM JK02.SPShort;

• Revoking privileges

User Scott says:REVOKE SELECT ON SP FROM JK02 ;

Then user JK02 can’t say:SELECT * FROM Scott.SP;

and user Janusz can’t say:SELECT * FROM JK02.SPShort;

Page 49: 1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her

49

Access controlAccess control

• Bibliography

P. O’Neil, Database - Principles, Programming, Performance, chapter 6.3

R. Elmasri, S.B. Navathe, Fundamentals of Database Systems, chapter 20.1, 20.2

R. K. Stephens, et al. Teach Yourself SQL in 21 Days

• Bibliography

P. O’Neil, Database - Principles, Programming, Performance, chapter 6.3

R. Elmasri, S.B. Navathe, Fundamentals of Database Systems, chapter 20.1, 20.2

R. K. Stephens, et al. Teach Yourself SQL in 21 Days