Reader small image

You're reading from  Oracle Database 12c Security Cookbook

Product typeBook
Published inJun 2016
PublisherPackt
ISBN-139781782172123
Edition1st Edition
Right arrow
Authors (2):
Zoran Pavlovic
Zoran Pavlovic
author image
Zoran Pavlovic

Zoran Pavlovic is currently working as an Oracle Technical Architect in his company. He works with Oracle technologies (primary Oracle Database) since 2005. Areas of his expertise are Security and Performance Tuning of Oracle Database. Zoran has worked on various complex database environments including RAC, ASM, Data Guard, etc. He has worked as a consultant for Oracle Consulting as well as instructor for Oracle University across EMEA region. Zoran is first member of Oracle ACE Program in Serbia, and a featured speaker/author at many conferences/magazines.
Read more about Zoran Pavlovic

Maja Veselica
Maja Veselica
author image
Maja Veselica

Maja Veselica, MSc in software engineering, is currently working for Parallel d.o.o., Belgrade, as an Oracle Database consultant (security, performance tuning, and so on). She has been working as an instructor for Oracle University since 2010. In the last couple of years, she has also been working for Oracle Consulting. Also, Maja is a member of Oracle ACE Program and has more than 20 Oracle certificates. She enjoys (beta) testing Oracle products and participating in other Oracle-related activities.
Read more about Maja Veselica

View More author details
Right arrow

Chapter 2. Security Considerations in Multitenant Environment

In this chapter, we will cover the following tasks:

  • Creating a common user

  • Creating a local user

  • Creating a common role

  • Creating a local role

  • Granting privileges commonly

  • Granting privileges locally

  • Granting common and local roles

  • The effects of plugging/unplugging operations on users, roles, and privileges

Introduction


The Oracle multitenant environment is a new architecture of Oracle Database, introduced in version 12c (12.1.0.1). It brings major changes to the way Oracle Database administrators think about the concept of databases and how they work (in a multitenant environment). One of the most significant changes is that many databases (up to 252) can share one database instance.

This chapter is focused on some of the security considerations concerning common and local users, roles, and privileges. The prerequisite for understanding recipes in this chapter is to have at least basic knowledge of fundamental multitenant concepts, such as what is a container database (CDB), pluggable database (PDB), root container, and seed.

Figure 1 shows the traditional architecture of Oracle Database.

Figure 1 - A traditional architecture

Figure 2 shows the separation of the data dictionary in a multitenant architecture:

Figure 2 - Data Dictionary separation

Figure 3 shows a multitenant architecture. To learn...

Creating a common user


A common user is a user created in the root container, which has the same identity across all containers. The main purpose of a common user is to perform "infrastructure" administrative tasks, such as starting up a CDB, plugging and unplugging PDBs, and opening PDBs. There are two types of common users: Oracle-supplied (for example, SYS and SYSTEM) and user-created common users.

Getting ready

To complete this recipe, you'll need an existing common user who has create user privilege granted commonly.

How to do it...

  1. Connect to the root container as a common user who has create user privilege granted commonly (for example, c##zoran or system user):

           SQL> connect c##zoran@cdb1
    
    
  2. Create a common user (for example, c##maja):

           c##zoran@CDB1> create user c##maja identified by oracle1
           container=all;  
    
    

How it works...

c##maja is actually not a single user, but each container has a user named c##maja and the passwords must be the same.

Figure...

Creating a local user


A local user is a user that is created and that exists in only one PDB. A local user can't be created in the root container.

Getting ready

A pluggable database (in our case, pdb1) should be open. You'll need an existing user (either common or local) who has create user privilege in that pluggable database.

How to do it...

  1. Connect to PDB (for example, pdb1) as a common user or local user who has      create user privilege in that PDB (for example, c##zoran or system user):

           SQL> connect c##zoran@pdb1
    
  2. Create a local user (for example, mike):

           c##zoran@PDB1> create user mike identified by pa3t5brii
           container=current;
    

How it works...

Figure 9

Rules/guidelines for creating and managing local users

There are a few rules you should be aware of:

  • The name of a local user must be unique within its pluggable database and it must not begin with c## or C##

  • A local user cannot be created in the root

  • A local user exists in one and only one PDB and owns a schema...

Creating a common role


Common roles are roles created in the root container and they exist in all containers. These roles can have a different set of privileges in different containers and they can be granted to either common or local users or roles.

Getting ready

To complete this recipe, you'll need an existing common user who has create role privilege granted commonly.

How to do it...

  1. Connect to the root container as a common user who has create role privilege granted commonly (for example, c##zoran or system user):

    SQL> connect c##zoran@cdb1
    
  2. Create a common role (for example, c##role1):

    SQL> create role c##role1 container=all;
    

How it works...

When you create a common role, that role exists in all containers in that database (including a root container and existing and future pluggable databases).

Figure 12

c##zoran@CDB1> select * from dba_roles where role='C##ROLE1';
ROLE                  PASSWORD AUTHENTICAT   COM  O
----------------      --------  -----------  ---  -
C##ROLE1...

Creating a local role


Local roles are roles created in PDB and they exist only in that PDB. These roles can be granted only locally to either common or local users or roles.

Getting ready

For this recipe, a pluggable database (in our case, pdb1) should be open. You'll need an existing user (either common or local) who has create role privilege in that pluggable database.

How to do it...

  1. Connect to PDB (for example, pdb1) as a common or local user who has        create role privilege in that PDB (for example, c##maja):

    SQL> connect c##maja@pdb1
    
  2. Create a local role (for example, local_role1):

    c##maja@PDB1> create role local_role1 container=current;
    

How it works...

When you create a local role, that role exists only in the pluggable database in which it is created. Local roles cannot be created in the root container. These roles are traditional roles.

Figure 15

c##maja@CDB1> select * from dba_roles where role='LOCAL_ROLE1';


    no rows selected



    c##maja...

Granting privileges and roles commonly


The common privilege is a privilege that can be exercised across all containers in a container database. Depending only on the way it is granted, a privilege becomes common or local. When you grant a privilege commonly (across all containers) it becomes a common privilege. Only common users or roles can have common privileges. Only common role can be granted commonly.

Getting ready

For this recipe, you will need to connect to the root container as an existing common user who is able to grant a specific privilege or existing role (in our case, create session, select any table, c##role1, c##role2) to another existing common user (c##john). If you want to try out examples in the How it works section, you should open pdb1 and pdb2.

You will use the following:

  • Common users c##maja and c##zoran with the dba role granted commonly

  • Common user c##john

  • Common roles c##role1 and c##role2

How to do it...

  1. You should connect to the root container as a common user who can...

Granting privileges and roles locally


A local privilege is a privilege than can be exercised only in a container in which it is granted. Depending only on the way it is granted, a privilege becomes common or local. When you grant privilege locally (in the current container), it becomes a local privilege. Both common and local users or roles can have local privileges.

Getting ready

For this recipe, you'll need an existing user (c##maja) who can grant some privileges (for example, create procedure, create table, create view, and create synonym) and roles (c##role1, c##role2, c##role3, c##role4, and local_role1) in a specific container (root or PDB; in our case, pdb1) to existing users and roles (c##john, mike, local_role1, c##role1, c##role3, and c##role4).

How to do it...

  1. You should connect to the container (root or pluggable database) in which you want to grant the privilege as a common or local user who can grant that privilege (for example, c##maja):

    SQL> connect c##maja@pdb1
    
  2. Grant a privilege...

Effects of plugging/unplugging operations on users, roles, and privileges


The purpose of this recipe is to show what is going to happen to users, roles, and privileges when you unplug a pluggable database from one container database (cdb1) and plug it into some other container database (cdb2).

Getting ready

To complete this recipe, you will need the following:

  • Two container databases (cdb1 and cdb2)

  • One pluggable database (pdb1) in the container database cdb1

  • Local user mike in the pluggable database pdb1 with the local create session privilege

  • The common user c##john with the create session common privilege and create synonym local privilege on the pluggable database pdb1

How to do it...

  1. Connect to the root container of cdb1 as user sys:

    SQL> connect sys@cdb1 as sysdba
    
  2. Unplug pdb1 by creating an XML metadata file:

    SQL> alter pluggable database pdb1 unplug into 
           '/u02/oradata/pdb1.xml';
    
  3. Drop pdb1 and keep the datafiles:

    SQL> drop pluggable database pdb1 keep datafiles;
    
  4. Connect...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Oracle Database 12c Security Cookbook
Published in: Jun 2016Publisher: PacktISBN-13: 9781782172123
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Zoran Pavlovic

Zoran Pavlovic is currently working as an Oracle Technical Architect in his company. He works with Oracle technologies (primary Oracle Database) since 2005. Areas of his expertise are Security and Performance Tuning of Oracle Database. Zoran has worked on various complex database environments including RAC, ASM, Data Guard, etc. He has worked as a consultant for Oracle Consulting as well as instructor for Oracle University across EMEA region. Zoran is first member of Oracle ACE Program in Serbia, and a featured speaker/author at many conferences/magazines.
Read more about Zoran Pavlovic

author image
Maja Veselica

Maja Veselica, MSc in software engineering, is currently working for Parallel d.o.o., Belgrade, as an Oracle Database consultant (security, performance tuning, and so on). She has been working as an instructor for Oracle University since 2010. In the last couple of years, she has also been working for Oracle Consulting. Also, Maja is a member of Oracle ACE Program and has more than 20 Oracle certificates. She enjoys (beta) testing Oracle products and participating in other Oracle-related activities.
Read more about Maja Veselica