Oracle REST Data Services (ORDS) : Database Authentication
Use database authentication to provide basic authentication for your calls to PL/SQL from Oracle REST Data Services (ORDS).
oracle miscconfigurationintermediate
by OracleDba
14 views
Use database authentication to provide basic authentication for your calls to PL/SQL from Oracle REST Data Services (ORDS).
1234567891011121314151617181920
jdbc.auth.enabled=true
cd /u01/ords
# Default for all pools.
$JAVA_HOME/bin/java -jar ords.war set-property jdbc.auth.enabled true
# Specific pool.
$JAVA_HOME/bin/java -jar ords.war set-property
--conf pdb1
jdbc.auth.enabled true
<entry key="jdbc.auth.enabled">true</entry>
<entry key="security.requestValidationFunction">wwv_flow_epg_include_modules.authorize</entry>
$JAVA_HOME/bin/java -jar ords.war set-property security.requestValidationFunction ""
$CATALINA_HOME/bin/shutdown.sh
$CATALINA_HOME/bin/startup.sh1234567891011121314151617181920212223242526272829303132333435363738
CONN / AS SYSDBA
ALTER SESSION SET CONTAINER = pdb1;
CREATE USER api_owner IDENTIFIED BY api_owner ACCOUNT LOCK;
CREATE OR REPLACE PACKAGE api_owner.user_api AS
PROCEDURE display_user;
END user_api;
/
CREATE OR REPLACE PACKAGE BODY api_owner.user_api AS
PROCEDURE display_user AS
l_remote_user VARCHAR2(256);
BEGIN
l_remote_user := OWA_UTIL.get_cgi_env('REMOTE_USER');
OWA_UTIL.mime_header('application/json');
HTP.prn('{"remote-user":"' || l_remote_user || '"}' || CHR(10));
END display_user;
END user_api;
/
CREATE USER my_api_login_1 IDENTIFIED BY my_password1;
GRANT CREATE SESSION TO my_api_login_1;
GRANT EXECUTE ON api_owner.user_api TO my_api_login_1;
CREATE SYNONYM my_api_login_1.user_api FOR api_owner.user_api;
CREATE USER my_api_login_2 IDENTIFIED BY my_password2;
GRANT CREATE SESSION TO my_api_login_2;
GRANT EXECUTE ON api_owner.user_api TO my_api_login_2;
CREATE SYNONYM my_api_login_2.user_api FOR api_owner.user_api;12345678910111213141516171819
$ curl -s
-u "my_api_login_1:my_password1"
http://localhost:8080/ords/user_api.display_user
{"remote-user":"MY_API_LOGIN_1"}
$ curl -s
-u "my_api_login_2:my_password2"
http://localhost:8080/ords/user_api.display_user
{"remote-user":"MY_API_LOGIN_2"}
$
$ curl -ks
-u "my_api_login_1:my_password1"
https://localhost:8443/ords/user_api.display_user
{"remote-user":"MY_API_LOGIN_1"}
$ curl -ks
-u "my_api_login_2:my_password2"
https://localhost:8443/ords/user_api.display_user
{"remote-user":"MY_API_LOGIN_2"}
$123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
CONN my_api_login_1/my_password1@pdb1
BEGIN
ORDS.enable_schema(
p_enabled => TRUE,
p_schema => 'MY_API_LOGIN_1',
p_url_mapping_type => 'BASE_PATH',
p_url_mapping_pattern => 'customer1',
p_auto_rest_auth => FALSE
);
COMMIT;
END;
/
CONN my_api_login_2/my_password2@pdb1
BEGIN
ORDS.enable_schema(
p_enabled => TRUE,
p_schema => 'MY_API_LOGIN_2',
p_url_mapping_type => 'BASE_PATH',
p_url_mapping_pattern => 'customer2',
p_auto_rest_auth => FALSE
);
COMMIT;
END;
/
$ curl -ks -u "
my_api_login_1:my_password1
" https://localhost:8443/ords/
customer1
/user_api.display_user
{"remote-user":"MY_API_LOGIN_1"}
$ curl -ks -u "
my_api_login_2:my_password2
" https://localhost:8443/ords/
customer2
/user_api.display_user
{"remote-user":"MY_API_LOGIN_2"}
$
$ curl -iks -u "
my_api_login_1
:my_password1" https://localhost:8443/ords/
customer2
/user_api.display_user | grep HTTP
HTTP/1.1 404
$ curl -iks -u "
my_api_login_2
:my_password2" https://localhost:8443/ords/
customer1
/user_api.display_user | grep HTTP
HTTP/1.1 404
$Please to add comments
No comments yet. Be the first to comment!