wallet_acl_network_access
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| wallet_acl_network_access [2018/12/08 12:49] – created 0.0.0.0 | wallet_acl_network_access [2020/10/25 14:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Wallet_/ | ||
| - | |||
| Nice, clear example found on [[https:// | Nice, clear example found on [[https:// | ||
| - | =====Create a wallet===== | + | * Another one by Franck Pachot [[https://medium.com/@FranckPachot/passwordless-data-pump-19c-b21cd1e00c16|Passwordless Data Pump 19c|Passwordless Data Pump 19c]] - duplicated at the bottom of this page in case it disappears! |
| - | < | + | |
| - | =====Create an ACL===== | + | |
| - | < | + | |
| - | =====Add privilege to ACL===== | + | |
| - | < | + | |
| - | =====Open | + | |
| - | < | + | |
| - | =====Configure Fine-Grained Access to External Network Services===== | + | ==== Create a wallet ==== |
| - | * From [[http:// | + | < |
| - | Oracle Database 11g Release 1 (11.1) includes fine-grained access control to the UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP, or UTL_INADDR packages using Oracle XML DB.<br /> | + | mkdir / |
| - | If you have applications that use one of these packages, you must install Oracle XML DB if it is not already installed.<br /> | + | orapki wallet create -wallet / |
| - | You must also configure network access control lists (ACLs) in the database before these packages can work as they did in prior releases.<br /> | + | orapki wallet add -wallet / |
| - | <br /> | + | orapki wallet add -wallet / |
| - | The following example first looks for any ACL currently assigned to host_name.<br /> | + | orapki wallet add -wallet / |
| - | If one is found, then the example grants user_name the CONNECT privilege in the ACL only if that user does not already have it.<br /> | + | </ |
| + | ==== Create an ACL ==== | ||
| + | < | ||
| + | begin | ||
| + | dbms_network_acl_admin.create_acl ( acl => ' | ||
| + | , description | ||
| + | , principal | ||
| + | , is_grant | ||
| + | , privilege | ||
| + | , start_date | ||
| + | , end_date | ||
| + | ); | ||
| + | commit; | ||
| + | end; | ||
| + | / | ||
| + | </ | ||
| + | ==== Add privilege to ACL ==== | ||
| + | < | ||
| + | begin | ||
| + | dbms_network_acl_admin.add_privilege ( acl => ' | ||
| + | , principal | ||
| + | , is_grant | ||
| + | , privilege | ||
| + | , position | ||
| + | , start_date | ||
| + | , end_date | ||
| + | ); | ||
| + | |||
| + | commit; | ||
| + | end; | ||
| + | / | ||
| + | </ | ||
| + | ==== Open the wallet and use UTL_HTTP to retrieve a web page ==== | ||
| + | < | ||
| + | set serverout on | ||
| + | declare | ||
| + | l_url varchar2(100) := ' | ||
| + | l_req utl_http.req; | ||
| + | l_result | ||
| + | l_data | ||
| + | begin | ||
| + | utl_http.set_wallet(' | ||
| + | l_req := utl_http.begin_request(l_url); | ||
| + | l_result := utl_http.get_response(l_req); | ||
| + | |||
| + | begin | ||
| + | loop | ||
| + | utl_http.read_text(l_result, | ||
| + | dbms_output.put_line (l_data); | ||
| + | end loop; | ||
| + | exception | ||
| + | when utl_http.end_of_body then | ||
| + | utl_http.end_response(l_result); | ||
| + | end; | ||
| + | end; | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Configure Fine-Grained Access to External Network Services ==== | ||
| + | * From [[http:// | ||
| + | Oracle Database 11g Release 1 (11.1) includes fine-grained access control to the UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP, or UTL_INADDR packages using Oracle XML DB.\\ | ||
| + | If you have applications that use one of these packages, you must install Oracle XML DB if it is not already installed.\\ | ||
| + | You must also configure network access control lists (ACLs) in the database before these packages can work as they did in prior releases.\\ | ||
| + | |||
| + | The following example first looks for any ACL currently assigned to host_name.\\ | ||
| + | If one is found, then the example grants user_name the CONNECT privilege in the ACL only if that user does not already have it.\\ | ||
| If no ACL exists for host_name, then the example creates a new ACL called ACL_name, grants the CONNECT privilege to user_name, and assigns the ACL to host_name. | If no ACL exists for host_name, then the example creates a new ACL called ACL_name, grants the CONNECT privilege to user_name, and assigns the ACL to host_name. | ||
| - | < | + | < |
| + | DECLARE | ||
| + | acl_path | ||
| + | BEGIN | ||
| + | SELECT acl INTO acl_path | ||
| + | FROM | ||
| + | WHERE host = ' | ||
| + | AND lower_port IS NULL | ||
| + | AND upper_port IS NULL; | ||
| + | IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(acl_path, | ||
| + | DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl_path, | ||
| + | END IF; | ||
| + | EXCEPTION | ||
| + | WHEN no_data_found THEN | ||
| + | DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(' | ||
| + | DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(' | ||
| + | END; | ||
| + | COMMIT; | ||
| + | </ | ||
| + | |||
| + | ==== Create a wallet for use with Data Pump in 19c ==== | ||
| + | Reference: [[https:// | ||
| + | |||
| + | There’s a very light bug with a very simple workaround, but it may require a little change in scripts. If you use passwordless authentication (external password file or OS authentication) with Data Pump in 19c it will ask for the password. The solution is just to answer whatever you want because the external authentication will be used anyway. | ||
| + | * [[https:// | ||
| + | === Example === | ||
| + | I create the wallet | ||
| + | < | ||
| + | mkstore -wrl $ORACLE_HOME/ | ||
| + | w4ll3t-P455w0rd | ||
| + | w4ll3t-P455w0rd | ||
| + | CREATE | ||
| + | </ | ||
| + | |||
| + | I create a tnsnames.ora entry that I’ll use to connect: | ||
| + | < | ||
| + | cat >> $ORACLE_HOME/ | ||
| + | CDB1A_SYSTEM=(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=CDB1A))(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) | ||
| + | CAT | ||
| + | </ | ||
| + | I add a credential for this entry — here SYSTEM user and its password: | ||
| + | < | ||
| + | mkstore -wrl $ORACLE_HOME/ | ||
| + | | ||
| + | user-P455w0rd | ||
| + | user-P455w0rd | ||
| + | w4ll3t-P455w0rd | ||
| + | CREATE | ||
| + | </ | ||
| + | I also add a credential for Eazy Connect Plus (see this previous post for the dummy parameter): | ||
| + | < | ||
| + | mkstore -wrl $ORACLE_HOME/ | ||
| + | // | ||
| + | user-P455w0rd | ||
| + | user-P455w0rd | ||
| + | w4ll3t-P455w0rd | ||
| + | CREATE | ||
| + | </ | ||
| + | Finally, I set the sqlnet.ora for this: | ||
| + | < | ||
| + | cat >> $ORACLE_HOME/ | ||
| + | WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=" | ||
| + | SQLNET.WALLET_OVERRIDE=TRUE | ||
| + | CAT | ||
| + | </ | ||
| + | Then, I can connect passwordless | ||
| + | < | ||
| + | connect /@CDB1A_SYSTEM | ||
| + | show user | ||
| + | show con_name | ||
| + | connect / | ||
| + | show user | ||
| + | show con_name | ||
| + | </ | ||
| + | |||
| + | Nothing new here. It is an old feature and very simple to setup. In 2019 we do not see any password in clear text in scripts or command line, right? | ||
| + | Data Pump expdp/ | ||
| + | But let’s try to use the same with Data Pump | ||
| + | < | ||
| + | expdp / | ||
| + | </ | ||
| + | |||
| + | I want to connect passwordless because the password is in the wallet, but Data Pump asks me for the password. Don’t worry: it asks but doesn’t care. The connection will use the wallet one. Then the solution is to send /dev/null as the stdin: | ||
| + | |||
| + | === “/ as sysdba” === | ||
| + | There’s the same when using OS authentication like running expdp or impdp connected SYSDBA. Note that this is not a recommendation: | ||
| + | '' | ||
| + | |||
| + | Of course, another reason not to use this is that OS authentication connects you to the CDB$ROOT where you should not have a lot to export… | ||
| + | Fixed in 20.1 | ||
| + | After writing this I realize that there’s now a MOS note about it, a patch and a solution (Upgrade to 20.1 when available): https:// | ||
| + | |||
wallet_acl_network_access.1544273361.txt.gz · Last modified: 2018/12/08 12:49 by 0.0.0.0
