4.7 Securing RESTful Web Services
Define roles, privileges and OAuth Clients to ensure authentication and authorization are required for accessing RESTful web services.
To protect a RESTful web service, you need to:
-
Create a role
-
Create a privilege selecting the role and modules or resources to protect
To enable access to a protected RESTful service using the OAUTH2 Workflow, create an OAuth client using the role and privilege created for protecting the RESTful service.
The following sections provide information on how to create roles, privileges and OAuth clients:
4.7.1 Managing Roles
You can create, edit and delete roles for RESTful services in the Roles page.
To navigate to the Roles page, from the REST Overview page, click Roles in Objects, or from the menu in the header, select Security and then select Roles.
The actions available in the context menu are:
4.7.2 Managing Privileges
You can create, edit and delete privileges for RESTful services in the Privileges page.
A privilege defines the set of roles, at least one of which an authenticated user must possess to access a RESTful service protected by a privilege.
To navigate to the Privileges page, from the REST Overview page, click Privileges in Objects, or from the menu in the header, select Security and then select Privileges.
The privilege attributes displayed by default in card view are shown in the following figure.
The actions available in the context menu are:
4.7.3 Managing OAuth Clients
Using OAuth 2.0-based authentication, you can ensure that your RESTful web services are accessed only by specific users or clients.
OAuth 2.0 is a standard Internet protocol that defines flows to provide conditional and limited access to a RESTful API. For more information, see OAuth-Based Authentication .
You can create, edit and delete OAuth Clients in the OAuth Clients page.
To navigate to the OAuth Clients page, from the REST Overview page, click Clients in Objects, or from the menu in the header, select Security and then select OAuth Client.
The OAuth Client attributes displayed by default in card view are shown in the following figure.
To create an OAuth client, see Creating an OAuth Client.
The actions available in the context menu are:
-
Edit: See Editing an OAuth Client
-
Export: See Exporting an OAuth Client
-
Delete: See Deleting an OAuth Client
-
Get Bearer Token: This option is displayed only if the client is created with a non-encrypted client secret. It provides the access token to call the RESTful service for Client Credentials and Implicit OAuth grant types. See Creating an OAuth Client Using the Client Credentials Grant Type
-
Manage Secrets: Applicable for Client Credentials and Auth Code grant types. See Managing Secrets
- Rotate: Removes the existing client secret and generates a new one for the OAuth client.
- Revoke: Removes the client secret associated with the OAuth client.
-
Auth Details: Displays the Unique Value and Authorization URI for the Auth Code OAuth grant type. See Creating an OAuth Client Using the Auth Code Grant Type
4.7.3.1 Creating an OAuth Client
Creates the OAuth Client and grants the required roles and privileges.
4.7.3.3 Deleting an OAuth Client
This section describes how to delete an OAuth Client.
- In the OAuth Clients page, for the specific client, click
Actions
and select Delete.
- You are prompted to confirm. Click Yes.
4.7.3.4 Exporting an OAuth Client
This section describes how to export an OAuth Client.
- In the OAuth Clients page, for the specific client, click
Actions
and select Export.
- In the OAuth Client panel, click the Copy icon or Download to copy or download the OAuth Client information.
4.7.3.5 Managing Secrets
After a client secret is generated for an OAuth client, you can rotate or revoke the secret when required. The Rotate and Revoke options are available in the specific OAuth client's context menu.
Note:
With the deprecation of OAUTH and OAUTH_ADMIN PL/SQL packages (see ORDS_SECURITY PL/SQL Package Reference ), the OAuth client secret creation process changes for Client Credentials and Auth Code grant types.
For OAuth clients that have been created with a non-encrypted
secret, the label Legacy
is displayed on the card.
Rotate a Client Secret
Removes the existing secret and creates a new one. This is useful when you cannot remember the existing client secret value.
-
If a client secret exists for the OAuth client, click Rotate to remove the existing one and generate a new client secret.
-
If a client secret is revoked and there is no secret value assigned, click Register to generate a client secret for the OAuth client.
Revoke a Client Secret
Removes the existing client secret.
Select Revoke sessions to remove all existing client sessions.
4.7.4 Examples
This section provides a few examples on creating an OAuth client with different grant types.
4.7.4.1 Creating an OAuth Client Using the Client Credentials Grant Type
This section describes how to create an OAuth Client using the Client Credential grant type.
Create an OAuth Client for the created module "example" in Example: Inserting a Record using a POST Handler. The endpoint for the RESTful service is http://xyz.us.comp.com:1234/ords/pdbdba/example/emp/.
Prerequisites
Create a role named HR Admin. See Creating a Role
Create a privilege named Example.HR. See Creating a Privilege