20211120 - 로그인 인증 후 권한에 따른 메뉴 조회 Authorized Menu, Custom Navigation Menu

1. Shared Component >> Navigation Menu >> Create

Create List from Scratch



Name : Dynamic Navigation Menu

Type : Dynamic





2. User Interface Attribute

Navigation Menu >> Dynamic Navigation Menu 선택 


3. 로그인 후 권한에 따른 메뉴 구성




4. 권한별 메뉴 리스트에 대한 ERD 참고


SQL 참고

select level        "level"
     , page_nm      "label"
     , entry_target "target"
     , 'YES'        is_current
     , ''           image
  from (
         select mpage.page_nm, mpage.entry_target, mpage.dpseq, mgdtl.page_id, mgdtl.ppage_id
           from menu_grp_dtl mgdtl
              , menu_page    mpage
          where mgdtl.page_id  = mpage.page_id
            and mgdtl.mgrp_id in (
         select mgrp.mgrp_id
           from role_menu_grp rmgrp
              , user_mst      usermst
              , menu_grp      mgrp
          where upper(usermst.login_id) = :APP_USER
            and rmgrp.role = usermst.role
            and rmgrp.mgrp_id = mgrp.mgrp_id )
       ) menu_page
start with
    ppage_id = 1
connect by
    prior page_id = ppage_id
    order siblings by dpseq


참고.


20211120 - 커스텀 로그인 사용자 테이블 인증 Custom Authentication

1. 커스텀 인증 방식 생성

Name : CustomMyAuth

Scheme Type : Custom 

Authentication Function Name : F_AUTHENTICATE_USER



2. 함수 생성


create or replace FUNCTION F_AUTHENTICATE_USER
  (p_username in varchar2, 
   p_password in varchar2)
return boolean
is
  l_user_name       user_mst.login_id%type := upper(p_username);
  l_password        varchar2(255); --users.password%type;
  l_hashed_password varchar2(1000);
  l_count           number;
begin
-- Returns from the AUTHENTICATE_USER function 
--    0    Normal, successful authentication
--    1    Unknown User Name
--    2    Account Locked
--    3    Account Expired
--    4    Incorrect Password
--    5    Password First Use
--    6    Maximum Login Attempts Exceeded
--    7    Unknown Internal Error
--
-- First, check to see if the user exists
    select count(*) 
      into l_count 
      from user_mst
     where upper(login_id) = l_user_name
       and use_yn    = 'Y';
      
     if l_count > 0 then
          -- Hash the password provided
          l_hashed_password := '1';--hash_password(l_user_name, p_password);
          l_password := '1';
          -- Get the stored password
          /*
          select password 
            into l_password 
            from users 
           where user_name = l_user_name; */
  
          -- Compare the two, and if there is a match, return TRUE
          if l_hashed_password = l_password then
              -- Good result. 
              APEX_UTIL.SET_AUTHENTICATION_RESULT(0);
              return true;
          else
              -- The Passwords didn't match
              APEX_UTIL.SET_AUTHENTICATION_RESULT(4);
              return false;
          end if;
  
    else
          -- The username does not exist
          APEX_UTIL.SET_AUTHENTICATION_RESULT(1);
          return false;
    end if;
    -- If we get here then something weird happened. 
    APEX_UTIL.SET_AUTHENTICATION_RESULT(7);
    return false;
exception 
    when others then 
        -- We don't know what happened so log an unknown internal error
        APEX_UTIL.SET_AUTHENTICATION_RESULT(7);
        -- And save the SQL Error Message to the Auth Status.
        APEX_UTIL.SET_CUSTOM_AUTH_STATUS(sqlerrm);
        return false;
        
end f_authenticate_user;


3. 커스텀 인증 방식을 현재 인증 방식으로 설정


* 주의 : 로그인 ID 가 로그인 테이블에 소문자로 저장되어 있어도 세션에 저장되는 :APP_USER 값은 대문자임. 


참고.

https://blogs.oracle.com/apex/post/custom-authentication-and-authorization-using-built-in-apex-access-control-a-how-to


20211118 - Let's Encrypt SSL, certbot renewal

1. Let's Encrypt 무료 SSL을 사용하고 있고 조만간 만료가 예정되어 있음


2. 보안을 위해서 package 들을 최신 상태로 업데이트하고 certbot certonly 실행

아니면 certbot renew 로 하면 물어보는 창 없이 바로 실행됨


-- Let's Encrypt
-----------------
sudo su -
yum update -y

certbot certonly

pip install -U pip
pip install cryptography --upgrade

certbot certonly

nginx -t
nginx -s reload

-------------------
certbot renew

systemctl stop nginx
systemctl start nginx
systemctl status nginx











별개의 추가 설정 사항
vi /etc/nginx/conf.d/jkincloud.com.conf

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;






Cron Job

vi /root/othermonthrenew.sh

certbot renew --force-renewal

systemctl stop nginx

systemctl start nginx

systemctl status nginx


crontab -e

1 0 1 2,4,6,8,10,12 * /root/othermonthrenew.sh >> /tmp/othermonthrenew.log 2>&1


chmod +x /root/othermonthrenew.sh


ex)


1 11 3 * * <SHELL_PATH>
분 시 일 월 요일 쉘스크립트경로


매월 첫째주 일요일 새벽 1시

0 1 * * 0 [ "$(date +\%d)" -le 07 ] && /path/to/your/script.sh


------------------
timedatectl
sudo timedatectl set-timezone Asia/Seoul
timedatectl
sudo systemctl restart chronyd
date

sudo shutdown -r
------------------

sudo timedatectl set-timezone Asia/Kuala_Lumpur


참고1

certbot certificates

certbot update_account --email yourname+1@example.com


https://eff-certbot.readthedocs.io/en/stable/using.html#automated-renewals


참고2

http://dgielis.blogspot.com/2019/12/free-oracle-cloud-16-renewing-lets.html

https://docs.oracle.com/en/learn/oracle-linux-crontab/index.html#check-your-cron-entry-output

https://jdm.kr/blog/2

https://velog.io/@jay2u8809/Crontab%ED%81%AC%EB%A1%A0%ED%83%AD-%EC%8B%9C%EA%B0%84-%EC%84%A4%EC%A0%95


20250202 - IG 다운로드 버튼 바로 보이기

JS initialization Code : function (config) {     var $ = apex.jQuery,         toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),  ...