Hi,
I have created a Web API with LANSA that runs with Basic Authority (User / Password - no tokens).
How can I receive the values for user and password that are delivered in the request fpor checking it with the entries in our authorization data base file?
This is the basic definition of the server routine:
Srvroutine Name(GetKatalog) Response(*HTTP #Context)
Define_Com Class(#Com_Home.GetKatalog) Name(#Operation)
* Instanzen von Request- und Response-Arrays definieren
Define_Com Class(#Com_Home.RequestArray) Name(#RequestArray)
Define_Com Class(#Com_Home.ResponseArray) Name(#ResponseArray)
* Zum Auslesen des empfangenen Requests
Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader) Reference(*DEFERRED)
Define_Com Class(#XPRIM_ErrorInfo) Name(#ErrorObject) Reference(*DEFERRED)
Define_Com Class(#PRIM_BOLN) Name(#Found)
Can I retrieve user/password with some #Operation values or how do I do this?
Kind regards,
Jörg
LANSA Web API with Basic Authority - User / Password
-
Joerg Hamacher
- Posts: 124
- Joined: Thu Feb 11, 2016 12:01 am
Re: LANSA Web API with Basic Authority - User / Password
Hi Joerg
If you mark the checkbox to generate security samples, you will get an example of how to get the user and password: you get this sample code:
If you mark the checkbox to generate security samples, you will get an example of how to get the user and password: you get this sample code:
Code: Select all
....
If (#Com_Owner.VerifyUsernamePassword( #Context #Operation.Request.Security ))
....
Code: Select all
Mthroutine Name(VerifyUsernamePassword)
Define_Map For(*RESULT) Class(#prim_boln) Name(#Verified)
Define_Map For(*INPUT) Class(#prim_srvm.HttpContext) Name(#Context) Pass(*BY_REFERENCE)
Define_Map For(*INPUT) Class(#com_home.Security) Name(#Security) Pass(*BY_REFERENCE)
If (#Security.HttpBasic.Username.LowerCase *EQ "user")
If (#Security.HttpBasic.Password.LowerCase *EQ "user123")
#Verified := true
Endif
Else
If (#Security.HttpBasic.Username.LowerCase *EQ "administrator")
If (#Security.HttpBasic.Password.LowerCase *EQ "admin123")
#Verified := true
Endif
Endif
Endif
Endroutine
-
Joerg Hamacher
- Posts: 124
- Joined: Thu Feb 11, 2016 12:01 am
Re: LANSA Web API with Basic Authority - User / Password
Hi Dino,
thank you very much for this information and best regards!
Joerg
thank you very much for this information and best regards!
Joerg