Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mCvtp-0004HV-J7 for pgsql-general@arkaria.postgresql.org; Mon, 09 Aug 2021 03:24:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mCvtn-0000MX-Nd for pgsql-general@arkaria.postgresql.org; Mon, 09 Aug 2021 03:24:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mCvtn-0008W6-6V for pgsql-general@lists.postgresql.org; Mon, 09 Aug 2021 03:24:23 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mCvtj-0007SQ-7R for pgsql-general@lists.postgresql.org; Mon, 09 Aug 2021 03:24:22 +0000 Received: by mail-qk1-x729.google.com with SMTP id e14so16973882qkg.3 for ; Sun, 08 Aug 2021 20:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=3yR647qt+jp9+dY2A41CqGGjuXKDlLHw7WnmUJ4HjJY=; b=SHQlseUZGi0R/ZjnCB5J2PK5a5Ti67xpXJToNnXZrnWrzqTMTrVFVPYAdMMN9Gcl2O qEqHAgaUGlN02REjtk9rzN4Qgn+qhbuVqYe2c8YqklNd/uZ2g9wSFievrLp5K/lGqzb7 DptZZsSiRE0KvJt/IuZYOhaYD9icNsKPsktWR7WqrclapQ22VfqFuIcBCJmXQqHDSFds WfBCwI/6ETj74l1J+/Hy6DE5VGErkx2wki7rIu+c+aeJIeh6UEBgKQTA1MhSnEB8PrcN Vfnbp2ITje4touO1HiMOmflCRPyd/Aj2mLZTHmAA1tYwm/tafvSHB6Mwa0CiExeyK/11 N55Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=3yR647qt+jp9+dY2A41CqGGjuXKDlLHw7WnmUJ4HjJY=; b=qatnLiBBwgQ3qYhAEIAxDiIX8WXp65d6xGs+17HD9fh799UIo01C40d1ZasKlV0JP5 oAoXezIhn8iaWvsKk7iWUicwfrG5O4dHK7vL2lBTfhOTrdFB6H8mXyiECrnb8hbrZZZr trmR2HmjeYBnNqjAT6i2Y0BlB3mNd/G3g4HBCDxVSF5KHV/ddiUzZO7wvD8uxFScsUK+ AOuZ/cqqqOTRL3R9ADf1z/FvQYbG+Mz3uLBoj049o4CPXVBeGAkj8rEN5xJFCSUbMA1E fSrh9fwXDcNM0+4SQX7we5h7FSaxPLpYsFDWwIs8OsMkjqDzy1BEpgZyHpQ3Qekhrk8S 823w== X-Gm-Message-State: AOAM530hZS/K4HEymvv+fS9lWLNzmjE4Umqv/n2KyQXgbm/yWlVK193x QvhEXqsgk/sk9NIKV2CRWpCf55Iwmj7HHQ== X-Google-Smtp-Source: ABdhPJyuJNZ/vrO9YCcCwWAE5wphXlm+xoCWPNqg5//uGpMgd7nHMT4Kgz4g6Egy4G8v4LJ+wvQnEQ== X-Received: by 2002:ae9:e30c:: with SMTP id v12mr12457517qkf.206.1628479456502; Sun, 08 Aug 2021 20:24:16 -0700 (PDT) Received: from [192.168.2.100] (pool-100-8-54-81.nwrknj.fios.verizon.net. [100.8.54.81]) by smtp.gmail.com with ESMTPSA id 191sm5658199qke.44.2021.08.08.20.24.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Aug 2021 20:24:15 -0700 (PDT) Subject: Re: JWT decoder To: pgsql-general@lists.postgresql.org References: <2138331050.291272.1628475372080.ref@mail.yahoo.com> <2138331050.291272.1628475372080@mail.yahoo.com> From: Mladen Gogala Message-ID: Date: Sun, 8 Aug 2021 23:24:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <2138331050.291272.1628475372080@mail.yahoo.com> Content-Type: multipart/alternative; boundary="------------683482D07FC32B6EB4E4A55F" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------683482D07FC32B6EB4E4A55F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit You could probably use Pl/Python. Python has base64 module and urllib module which can deal with all URL strings I am aware of. Pl/Perl would probably do as well. On 8/8/21 10:16 PM, Masih Tavassoli wrote: > Hi experts, > > I am trying to find a way to decode a URL request header and extract > its JSON fields in postgreql . > > I can do this in Oracle sql using > > select    (utl_raw.cast_to_varchar2 (utl_encode.base64_decode( > utl_raw.cast_to_raw (regexp_replace ( ( > 'eyJhbGciOiJSUzI1NiIsImtpZCI6InBhLWFwaS1zaWduIn0.eyJzY29wZSI6W10sInN1YiI6Imp1bGllQHNhcHBoaXJlY29udmV5YW5jaW5nLm5ldC5hdSIsImNsaWVudCI6InB4YV9hY19zZXR0c3BsdXMiLCJ1c2VybmFtZSI6Imp1bGllQHNhcHBoaXJlY29udmV5YW5jaW5nLm5ldC5hdSIsImV4cCI6MTU1NDA4NzU2N30.OZwVETCP+HUDsSkudCfa52eQT2Fyt6BgefFpYr5xpJROjZJeVnXtzsU6MS8aHauqyyOwQSz8iG6OC2YjYgrGiZ8YTwTh1uHptNjicyCFmCkh++d0oGdK78ZOKIAvuslW3GX4V13hPUJADzGLkyO8hy01YF9Id4+7GrvmnRRkwPO7C2eUvKTB8pxDAA94Jpw74s4BiNTmm1Uv+56AXqdI8m2KFkLNwGoUR3OSNvsifl5uxBsGGmP4wbgNe/Dy1q2UsL2eBAW/GuWryHGCRz1/PR2jIV1v21ClQ8YLiFAzM3YxHb8m2ngzRynKof+Nw3nZvuafRQ16MV5THz0ahGFYLA' > > ), '[[:space:]]', ''))))) from dual > > > > But there doesn't seem to be a way doing it in postgres. > > Has anyone got any suggesions? > > Thanks > Masih > -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------683482D07FC32B6EB4E4A55F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

You could probably use Pl/Python. Python has base64 module and urllib module which can deal with all URL strings I am aware of.  Pl/Perl would probably do as well.

On 8/8/21 10:16 PM, Masih Tavassoli wrote:
Hi experts,

I am trying to find a way to decode a URL request header and extract its JSON fields in postgreql .

I can do this in Oracle sql using 

select    (utl_raw.cast_to_varchar2 (utl_encode.base64_decode( utl_raw.cast_to_raw (regexp_replace ( ( 'eyJhbGciOiJSUzI1NiIsImtpZCI6InBhLWFwaS1zaWduIn0.eyJzY29wZSI6W10sInN1YiI6Imp1bGllQHNhcHBoaXJlY29udmV5YW5jaW5nLm5ldC5hdSIsImNsaWVudCI6InB4YV9hY19zZXR0c3BsdXMiLCJ1c2VybmFtZSI6Imp1bGllQHNhcHBoaXJlY29udmV5YW5jaW5nLm5ldC5hdSIsImV4cCI6MTU1NDA4NzU2N30.OZwVETCP+HUDsSkudCfa52eQT2Fyt6BgefFpYr5xpJROjZJeVnXtzsU6MS8aHauqyyOwQSz8iG6OC2YjYgrGiZ8YTwTh1uHptNjicyCFmCkh++d0oGdK78ZOKIAvuslW3GX4V13hPUJADzGLkyO8hy01YF9Id4+7GrvmnRRkwPO7C2eUvKTB8pxDAA94Jpw74s4BiNTmm1Uv+56AXqdI8m2KFkLNwGoUR3OSNvsifl5uxBsGGmP4wbgNe/Dy1q2UsL2eBAW/GuWryHGCRz1/PR2jIV1v21ClQ8YLiFAzM3YxHb8m2ngzRynKof+Nw3nZvuafRQ16MV5THz0ahGFYLA'

), '[[:space:]]', ''))))) from dual



But there doesn't seem to be a way doing it in postgres.

Has anyone got any suggesions?

Thanks
Masih

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------683482D07FC32B6EB4E4A55F--