Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright ©2014 Pearson Education, Inc. Chapter 8 Is it Secure? Chapter8.1.

Similar presentations


Presentation on theme: "Copyright ©2014 Pearson Education, Inc. Chapter 8 Is it Secure? Chapter8.1."— Presentation transcript:

1 Copyright ©2014 Pearson Education, Inc. Chapter 8 Is it Secure? Chapter8.1

2 Copyright ©2014 Pearson Education, Inc. Overview Security is essential for any database that will be put into production. One way to begin thinking about security is to look at two terms: Authentication Authorization Chapter8.2

3 Copyright ©2014 Pearson Education, Inc. Authentication Authentication is the process of determining if the person is, in fact, who he or she claims to be. This can be done in a variety of ways: Login name and password Certificate Biometrics Chapter8.3

4 Copyright ©2014 Pearson Education, Inc. Authorization Authorization is about “authorizing” a user to do things in the database. It involves setting permissions on objects and data. Chapter8.4

5 Copyright ©2014 Pearson Education, Inc. SQL Server Authentication SQL Server has two primary ways of authenticating users: Windows authentication SQL Server authentication Chapter8.5

6 Copyright ©2014 Pearson Education, Inc. Windows Authentication In Windows Authentication, a windows or Active Directory account is mapped to an SQL Server Account. The user logs into their Windows machine and accesses the SQL Server through this account. This is the preferred method of authentication. Chapter8.6

7 Copyright ©2014 Pearson Education, Inc. SQL Server Authentication In SQL Server or mixed authentication, a user is given a login name and a password for logging into the server. This is useful in environments where not every user has a Windows account. Chapter8.7

8 Copyright ©2014 Pearson Education, Inc. Example: Creating an SQL Server Login CREATE LOGIN StudentLogIn WITH PASSWORD=ʼp@ssw0rd1ʼ, DEFAULT_DATABASE=TutorManagement Chapter8.8

9 Copyright ©2014 Pearson Education, Inc. Roles Roles are collections of permissions. Rather than try to assign and maintain individual user permissions, users can be assigned to a role that provides a common set of permissions. Roles provide a much more efficient and maintainable way of controlling user access to the database. New roles can be created as needed and SQL Server provides a set of built-in roles. Chapter8.9

10 Copyright ©2014 Pearson Education, Inc. Table of Built-in Roles Database RoleDescription db_accessadminCan ALTER any User and create Schema db_backupoperatorGrants the user to back up and restore the particular database db_datareaderGrants the user SELECT on all Tables and Views in the database db_datawriterGrants the user INSERT, UPDATE, and DELETE permissions on all Tables and Views db_ddladminGrants the ability to CREATE or ALTER any database object db_denydatareaderDenies SELECT on all Tables and Views db_denydatawriterDenies INSERT,UPDATE, and DELETE on all Tables and Views db_ownerGrants ownership and full permissions on all database objects db_securityadminGranted the ability to ALTER roles and CREATE Schema publicGrants access to database but by default has no permissions on any objects. Every user is a member of public as well as any other roles. The public role cannot be removed. Chapter8.10

11 Copyright ©2014 Pearson Education, Inc. Example: Creating a Role USE TutorManagement Go CREATE ROLE StudentRole Chapter8.11

12 Copyright ©2014 Pearson Education, Inc. Schema Schema can be used to achieve results similar to roles. However, a role is a collection of permissions; a schema is a collection of objects owned by a schema. A user can be assigned to a schema and then assigned permissions on schema objects. When they log in, they will only see the objects in their schema. Chapter8.12

13 Copyright ©2014 Pearson Education, Inc. Analyzing Security Needs One way to analyze the security needs of a database is to look at security requirements of each type of database user. You can analyze those needs in terms of specific permissions on tables and objects. Chapter8.13

14 Copyright ©2014 Pearson Education, Inc. Analysis Example Table nameSELECTINSERTUPDATEDELETEConstraints Student TutorX A public subset of tutor info CourseX StudentCourse Ethnicity SessionXX* *Only for own sessions RequestX RequestNoteX Chapter8.14

15 Copyright ©2014 Pearson Education, Inc. Threat Analysis Threat analysis involves identifying all the ways a database can be harmed and then finding strategies to mitigate those threats. Databases can also be damaged by accidental actions. Analyzing threats is a complex and ongoing task. Chapter8.15

16 Copyright ©2014 Pearson Education, Inc. Threat Analysis Example RoleStudent ThreatDescription SELECTSee private information of other students INSERTFalse or inaccurate information in Student table UPDATE False or inaccurate information in the Session table, removing other students from scheduled sessions DELETE Chapter8.16

17 Copyright ©2014 Pearson Education, Inc. Disaster Recovery Disaster recovery means planning for the worst. Disasters can be manmade, such as an attack by a hacker or a major mistake by an administrator. Disasters can also be natural. Fires, floods, and earthquakes can destroy data. Chapter8.17

18 Copyright ©2014 Pearson Education, Inc. Disaster Recovery Plan A disaster recovery plan is a plan for how to recover data and its availability after various possible disasters. A disaster recovery plan consists of policies and procedures for disaster prevention and recovery. Chapter8.18

19 Copyright ©2014 Pearson Education, Inc. Policies Policies are rules for how to do things. For instance, a business could have a rule that all databases are backed up twice a day. Another policy could be that all backups are kept off-site in some secure place. Chapter8.19

20 Copyright ©2014 Pearson Education, Inc. Procedures Procedures are step-by-step instructions for how to do things. In a disaster plan procedures are the step-by-step instructions for implementing a policy. Chapter8.20

21 Copyright ©2014 Pearson Education, Inc. Backup Procedure Example We will maintain 4 portable hard drives. Each morning retrieve the two drives with the oldest backup date. Perform a full database backup to one of the drives at 11:00 AM. Back up the log files to the hard drive. Record the current date and time of the backup on the hard disk. Send an employee to deposit the hard drive in a safety deposit box at Westlake Security Co. At closing, around 5:00 PM, do a full backup to the second hard disk. Back up the log files to the hard disk. Record the date and time on the hard disk. Send an employee to deposit the hard drive in a safety deposit box at Westlake Security Co. (Westlake is open until 7). If Westlake is closed, the employee is to take the disk home and deposit it when he or she picks up the drives the next work day. Chapter8.21

22 Copyright ©2014 Pearson Education, Inc. Finding Solutions Implementing effective security measures can be very complex. You can use a mixture of schema roles and permissions. One approach is to build a layer of views and stored procedures to manage all user access. Chapter8.22

23 Copyright ©2014 Pearson Education, Inc. Views Views are essential stored queries. Ideally, each view corresponds to a particular “view” that a user has of the data. Views can be used to hide the underlying structure of the database. Views are accessed just like tables. Chapter8.23

24 Copyright ©2014 Pearson Education, Inc. Syntax for a View CREATE VIEW AS Chapter8.24

25 Copyright ©2014 Pearson Education, Inc. View Example CREATE VIEW vw_Sessions AS SELECT TutorLastName AS [Tutor], StudentKey AS [Student], SessionDateKey AS [Date], SessionTimeKey AS [Time], CourseKey AS [Course] FROM Tutor t INNER JOIN [Session] s ON t.TutorKey=s.TutorKey WHERE SessionDateKey >=GetDate() Chapter8.25

26 Copyright ©2014 Pearson Education, Inc. Stored Procedures Stored procedures consist of one or more SQL commands. They can take parameters from the user. They allow all the commands to be executed as a unit. They allow error checking and validation to help ensure a safe transaction. Chapter8.26

27 Copyright ©2014 Pearson Education, Inc. Stored Procedure Syntax CREATE PROC AS Chapter8.27

28 Copyright ©2014 Pearson Education, Inc. Stored Procedure Example CREATE PROCEDURE usp_StudentLogIn @studentKey nchar(10) AS IF EXISTS (SELECT * FROM student WHERE studentKey=@studentKey) BEGIN SELECT studentLastName FROM Student WHERE Studentkey=@studentKey END Chapter8.28

29 Copyright ©2014 Pearson Education, Inc. A Few Stored Procedure Notes The following slides discuss a few of the features of stored procedures, specifically: Parameters Variables If/else and blocks Transactions and try/catch blocks Chapter8.29

30 Copyright ©2014 Pearson Education, Inc. Parameters A parameter is a value passed to the stored procedure from the user. Parameters are listed after the CREATE Statement and before the AS. All parameters start with the @ symbol and must be given a data type: @studentKey nchar(10) Chapter8.30

31 Copyright ©2014 Pearson Education, Inc. Variables Variables are declared after the AS keyword and must be assigned values internally. Variables are declared with the DECLARE keyword. Variables can be assigned values with the SET or SELECT keywords. Chapter8.31

32 Copyright ©2014 Pearson Education, Inc. Variable Examples DECLARE @CourseKey NCHAR(10) SELECT @CourseKey=CourseKey FROM [Session] WHERE SessionDateKey=@SessionDateKey AND SessionTimeKey=@SessionTimeKey DECLARE @CurrentDate Date SET @CurrentDate=GetDate() Chapter8.32

33 Copyright ©2014 Pearson Education, Inc. IF ELSE BEGIN END It is possible to select among possibilities by using the IF and ELSE keywords. IF sets up the condition and what to do if the condition is true. ELSE describes what to do if the condition is false. BEGIN is used to mark the start of an IF or ELSE block. END is used to mark the end of the block. Chapter8.33

34 Copyright ©2014 Pearson Education, Inc. If Example IF EXISTS (SELECT * FROM student WHERE studentKey=@studentKey) BEGIN SELECT studentLastName FROM Student WHERE Studentkey=@studentKey END Chapter8.34

35 Copyright ©2014 Pearson Education, Inc. TRY CATCH TRANS TRY CATCH blocks can be used with transactions to catch any errors. The TRY tests the code for errors. If there are no errors the statements are committed to the database. If there are errors, the execution will go to the CATCH block and roll back the transaction. Chapter8.35

36 Copyright ©2014 Pearson Education, Inc. TRY CATCH Example BEGIN TRAN BEGIN TRY UPDATE [Session] SET StudentKey=@StudentKey WHERE SessionDateKey=@SessionDateKey AND SessionTimeKey=@SessionTimeKey COMMIT TRAN END TRY BEGIN CATCH ROLLBACK TRAN END CATCH Chapter8.36

37 Copyright ©2014 Pearson Education, Inc. Big Data Big data refers to the recent attempts to utilize extremely large stores of data, often of Exabyte scale, to glean as much information as possible about current trends. Big data often uses mixed structured and unstructured data, traditional databases, and also things like social media, emails, usage logs, etc. The tools for analyzing this data are still being developed, but big data is becoming more and more important as we go forward. Chapter8.37

38 Copyright ©2014 Pearson Education, Inc. Documentation It is crucial to document the security setup. Authentication types and policies should be spelled out. All roles and schema should be described. All stored procedures and views should be described. Disaster plans and all policies and procedures should be documented and readily available. Chapter8.38

39 Copyright ©2014 Pearson Education, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Chapter8.39


Download ppt "Copyright ©2014 Pearson Education, Inc. Chapter 8 Is it Secure? Chapter8.1."

Similar presentations


Ads by Google