AIX Open Source

 View Only
Expand all | Collapse all

requests-kerberos for AIX

  • 1.  requests-kerberos for AIX

    Posted Wed October 20, 2021 12:20 PM
    hi Team

    request-kerberos is the python module that is very widely used in in open source community.
    It can be installed from pip. but unfortunately, there is no working version for AIX.

    could IBM developer help port this module to AIX environment?

    ------------------------------
    Victor Liu
    ------------------------------


  • 2.  RE: requests-kerberos for AIX

    Posted Fri October 22, 2021 11:15 AM
    Hi Victor, 

    I looked at request-kerberos and it is failing because a dependency pykerberos needs some APIs (mempcpy and asprintf) those are not available on AIX.
    These APIs are part of gnu libc and not available in AIX libc. 
    To make request-kerberos available on AIX we will have to patch request-kerberos to either use alternate or make mempcpy and asprintf available.
    Is there any alternate you have for request-kerberos ? 


    ------------------------------
    SANKET RATHI
    ------------------------------



  • 3.  RE: requests-kerberos for AIX

    Posted Mon October 25, 2021 01:11 PM
    hi Sanket

    Thank so much for look into this,
    That is exactly the block is.
    For the moment, I am using curl 7.13 as alternates, and I have to call curl from python code. and I am seeing some blocker from curl dependency that may not allowed to be installed in production... it could be a dead end eventually unless I got requests-kerberos.
    I would prefer IBM can port requests-kerberos to AIX by making mempcpy and asprintf available...
    With that, it will significantly help accelerate code development in AIX.
    from open source community, I found GSSAPI that seems the low lever API of requests-kerberos, but I am not able to figure out how to use it...
    in my scenario, I have a pushed credential file (Ticket Granting Ticket) on AIX box to use for authentication to get token.
    If there is any code sample regarding how to use GSSAPI based on my scenario, I may able to skip requests-kerberos. 
    But porting requests-kerberos still have huge value... highly recommend IBM developer engaged for it.

    Thanks
    Victor

    ------------------------------
    Victor Liu
    ------------------------------



  • 4.  RE: requests-kerberos for AIX

    Posted Tue October 26, 2021 02:51 PM
    Thank you Victor for other pointers.
    We will add this package into our future list of packages and try to make it available from AIX toolbox.

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 5.  RE: requests-kerberos for AIX

    Posted Thu October 28, 2021 11:05 AM
    Thank you so much Sanket
    that would great if IBM can make requests-kerberos available in AIX toolbox
    do you have any date for timeline to share?

    ------------------------------
    Victor Liu
    ------------------------------



  • 6.  RE: requests-kerberos for AIX

    Posted Mon November 01, 2021 03:36 AM
    Hi Victor, 
    If we will be successful in port using workaround then by end of this quarter or early next year we should be able to publish.
    But if we will find non trivial issues then it may take more time.

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 7.  RE: requests-kerberos for AIX

    Posted Mon November 01, 2021 10:02 AM
    Thanks Sanket, I will follow up in December

    ------------------------------
    Victor Liu
    ------------------------------



  • 8.  RE: requests-kerberos for AIX

    Posted Mon December 06, 2021 09:52 AM
    Hi Sanket

    hope you are doing well, I just kindly follow up with the requests-kerberos package on AIX. how is the porting going? any obstacle or delay?
    Thanks for sharing any update

    Victor

    ------------------------------
    Victor Liu
    ------------------------------



  • 9.  RE: requests-kerberos for AIX

    Posted Tue December 07, 2021 08:04 AM
    Hi Victor, 

    Out porting is going well and I think we should be able to publish the package next month.

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 10.  RE: requests-kerberos for AIX

    Posted Tue December 07, 2021 10:25 AM
    Great, Thank you so much

    ------------------------------
    Victor Liu
    ------------------------------



  • 11.  RE: requests-kerberos for AIX

    Posted Mon January 10, 2022 11:25 AM
    Hi Sanket

    Happy New Year

    any update about requests-kerberos for AIX?

    ------------------------------
    Victor Liu
    ------------------------------



  • 12.  RE: requests-kerberos for AIX

    Posted Tue January 11, 2022 11:13 AM
    Hi Victor,
    A very happy new year to you too.
    We should be able to publish the package in couple of weeks.

    ------------------------------
    SANKET RATHI
    ------------------------------



  • 13.  RE: requests-kerberos for AIX

    Posted Wed January 12, 2022 10:09 AM
    thanks, please give an update once published. I can't wait to test it..


    ------------------------------
    Victor Liu
    ------------------------------



  • 14.  RE: requests-kerberos for AIX

    Posted Tue February 08, 2022 10:34 AM
    Hi Sanket

    Is the package published?

    ------------------------------
    Victor Liu
    ------------------------------



  • 15.  RE: requests-kerberos for AIX

    Posted Mon February 14, 2022 08:01 AM

    We have published requests-kerberos in AIX toolbox.
    https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/noarch/python3-requests-kerberos/



    ------------------------------
    RESHMA KUMAR
    ------------------------------



  • 16.  RE: requests-kerberos for AIX

    Posted Fri February 18, 2022 11:10 AM
    thanks a lot, will try

    ------------------------------
    Victor Liu
    ------------------------------



  • 17.  RE: requests-kerberos for AIX

    Posted Wed June 15, 2022 03:20 PM
    hi Reshma Kumar

    I am able to install it on AIX 7.2 with python3 upgraded to 3.7.12 along with couple of other RPM updates.
    now, I am having problem to use it, it keep throwing the module not found

    Traceback (most recent call last):

      File "get_ida_token_kerberos_tgt.py", line 3, in <module>

        import requests_kerberos

      File "/opt/freeware/lib/python3.7/site-packages/requests_kerberos/__init__.py", line 17, in <module>

        from .kerberos_ import HTTPKerberosAuth, REQUIRED, OPTIONAL, DISABLED

      File "/opt/freeware/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 6, in <module>

        import spnego

      File "/opt/freeware/lib/python3.7/site-packages/spnego/__init__.py", line 10, in <module>

        from spnego.auth import client, server

      File "/opt/freeware/lib/python3.7/site-packages/spnego/auth.py", line 7, in <module>

        from spnego._credssp import CredSSPProxy

      File "/opt/freeware/lib/python3.7/site-packages/spnego/_credssp.py", line 42, in <module>

        from spnego.tls import (

      File "/opt/freeware/lib/python3.7/site-packages/spnego/tls.py", line 10, in <module>

        from cryptography import x509

    ModuleNotFoundError: No module named 'cryptography'


    My code sample is like below:

    import requests
    import requests_kerberos

    payload = {'client_id': myclientid,
    'resource': mysource,
    'grant_type': 'client_credentials',
    'use_windows_client_authentication': 'true'}

    kerberos_auth = requests_kerberos.HTTPKerberosAuth(mutual_authentication=requests_kerberos.OPTIONAL, force_preemptive=True)

    adfs_endpoint = 'https://myurl'

    token_request = requests.post(url=adfs_endpoint, data=payload, auth=kerberos_auth)
    print(token_request.json())


    access_token = token_request.json().get('access_token')
    print(access_token)


    Could you help troubleshoot this? much appreciate





    ------------------------------
    Victor Liu
    ------------------------------



  • 18.  RE: requests-kerberos for AIX

    Posted Thu June 16, 2022 08:57 AM

    Looks like you are using python3_32 (32bit). Is there any specific reason for you using 32bit python3 instead of the default 64bit python3  ? 

    I see Toolbox python3-cryptography is built only in 64bit mode. 



    ------------------------------
    Ayappan P
    ------------------------------



  • 19.  RE: requests-kerberos for AIX

    Posted Thu June 16, 2022 04:23 PM
    Hi Ayappan

    Thanks for replying my message,
    I have verified the python3 link, it pointing to /opt/freeware/bin/python3.7m_64. so I am using 64 bit.

    root@:/root #which python3
    /opt/freeware/bin/python3
    root@:/root #ls -l /opt/freeware/bin/python3
    lrwxrwxrwx 1 root system 10 Jun 14 16:16 /opt/freeware/bin/python3 -> python3_64
    root@:/root #ls -l /opt/freeware/bin/python3_64
    lrwxrwxrwx 1 root system 12 Jun 14 16:16 /opt/freeware/bin/python3_64 -> python3.7_64
    root@:/root #ls -l /opt/freeware/bin/python3.7_64
    lrwxrwxrwx 1 root system 13 Jun 14 16:16 /opt/freeware/bin/python3.7_64 -> python3.7m_64

    and  I have python3-cryptography installed
    root@:/root #rpm -qa | grep crypto
    python3-cryptography-3.2.1-1.ppc



    ------------------------------
    Victor Liu
    ------------------------------



  • 20.  RE: requests-kerberos for AIX

    Posted Fri June 17, 2022 07:00 AM
    Okay. If you are invoking python3 (64bit), then " ModuleNotFoundError: No module named 'cryptography' " error should not come. 
    Try running the below and check. 
     python3 -c "import requests_kerberos" 


    ------------------------------
    Ayappan P
    ------------------------------



  • 21.  RE: requests-kerberos for AIX

    Posted Fri June 17, 2022 09:09 AM
    Hi Ayappan

    I got exact error from my code: 

    root@:/root #python3 -c "import requests_kerberos"
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/opt/freeware/lib/python3.7/site-packages/requests_kerberos/__init__.py", line 17, in <module>
    from .kerberos_ import HTTPKerberosAuth, REQUIRED, OPTIONAL, DISABLED
    File "/opt/freeware/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 6, in <module>
    import spnego
    File "/opt/freeware/lib/python3.7/site-packages/spnego/__init__.py", line 10, in <module>
    from spnego.auth import client, server
    File "/opt/freeware/lib/python3.7/site-packages/spnego/auth.py", line 7, in <module>
    from spnego._credssp import CredSSPProxy
    File "/opt/freeware/lib/python3.7/site-packages/spnego/_credssp.py", line 42, in <module>
    from spnego.tls import (
    File "/opt/freeware/lib/python3.7/site-packages/spnego/tls.py", line 10, in <module>
    from cryptography import x509
    ModuleNotFoundError: No module named 'cryptography'

    What should I do?

    ------------------------------
    Victor Liu
    ------------------------------



  • 22.  RE: requests-kerberos for AIX

    Posted Fri June 17, 2022 09:16 AM
    Can you reinstall python3-cryptography rpm and check again.

    ------------------------------
    Ayappan P
    ------------------------------



  • 23.  RE: requests-kerberos for AIX

    Posted Fri June 24, 2022 08:14 AM
    Hi Ayappan 
    cryptography rpm is reinstalled and seems okay, but got another module missing  gssapi

    root@:/opt/misc/s3_mercury_api/src #python3 get_ida_token_kerberos_tgt.py

    KRB5_CONFIG: /etc/krb5.conf

    KRB5CCNAME: /var/sophiakrb/jacob_s3_mercury/cc/krb5cc_jacob_s3_mercury

    Traceback (most recent call last):

      File "get_ida_token_kerberos_tgt.py", line 22, in <module>

        token_request = requests.post(url=adfs_endpoint, data=payload, auth=kerberos_auth)

      File "/opt/freeware/lib/python3.7/site-packages/requests/api.py", line 116, in post

        return request('post', url, data=data, json=json, **kwargs)

      File "/opt/freeware/lib/python3.7/site-packages/requests/api.py", line 60, in request

        return session.request(method=method, url=url, **kwargs)

      File "/opt/freeware/lib/python3.7/site-packages/requests/sessions.py", line 519, in request

        prep = self.prepare_request(req)

      File "/opt/freeware/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request

        hooks=merge_hooks(request.hooks, self.hooks),

      File "/opt/freeware/lib/python3.7/site-packages/requests/models.py", line 317, in prepare

        self.prepare_auth(auth, url)

      File "/opt/freeware/lib/python3.7/site-packages/requests/models.py", line 548, in prepare_auth

        r = auth(self)

      File "/opt/freeware/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 390, in __call__

        auth_header = self.generate_request_header(None, host, is_preemptive=True)

      File "/opt/freeware/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 216, in generate_request_header

        protocol="kerberos",

      File "/opt/freeware/lib/python3.7/site-packages/spnego/auth.py", line 108, in client

        'initiate', **kwargs)

      File "/opt/freeware/lib/python3.7/site-packages/spnego/auth.py", line 77, in _new_context

        return proxy(username, password, hostname, service, channel_bindings, context_req, usage, proto, options, **kwargs)

      File "/opt/freeware/lib/python3.7/site-packages/spnego/_gss.py", line 362, in __init__

        raise ImportError("GSSAPIProxy requires the Python gssapi library: %s" % GSSAPI_IMP_ERR)

    ImportError: GSSAPIProxy requires the Python gssapi library: No module named 'gssapi'


    Could you help test it and make the whole thing easier?

    Thanks
    Victor

    ------------------------------
    Victor Liu
    ------------------------------



  • 24.  RE: requests-kerberos for AIX

    Posted Fri June 24, 2022 08:32 AM

    Addtionto gssapi issue. Is krb-config needed and will it solve the issue. Where can we get the package? We have installed all krb related fileset frpm expansion pack but to of no help.

    Thanks
    Victor



    ------------------------------
    Victor Liu
    ------------------------------



  • 25.  RE: requests-kerberos for AIX

    Posted Mon June 27, 2022 03:14 AM
    I think the original request was to provide request-kerberos through AIX Toolbox. 
    If gssapi is also needed for this use-case, then you can try to install it with pip. 
    " python3 -m pip install gssapi ".
    You need to have krb5-libs,  krb5-devel & gcc rpm packages installed in the machine.

    ------------------------------
    Ayappan P
    ------------------------------



  • 26.  RE: requests-kerberos for AIX

    Posted Tue July 05, 2022 10:37 AM
    Thanks Ayappan for the instruction

    we are trying to get the prerequisite of gssapi installed.
    yes, the original request is for  requests-kerberos, but we don't know the dependency is so deep until test it in the code.
    hope no need to port any other rpm for AIX.

    Best Regards
    Victor

    ------------------------------
    Victor Liu
    ------------------------------



  • 27.  RE: requests-kerberos for AIX

    Posted Tue July 05, 2022 12:39 PM
    The problem with providing python packages like requests-kerberos, gssapi as a rpm package in Toolbox is that the dependencies go deep and it will take lot of effort to port & maintain them. These packages change quickly and new dependencies get in every time we update the version in Toolbox.
    So pip install is the way to go here.

    ------------------------------
    Ayappan P
    ------------------------------