|
|
(36 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | {{DISPLAYTITLE:i2Rest Advanced Setup}}
| + | This section describes configuration options of i2Rest Server. [[I2Rest_quick_config|Basic configuration]] allows only demo server functionality, and must be extended to supply full functional server instancence. Combining examples bellow you can achieve server functionality that suits your requirements. <br> |
− | We assume that you have completed our [[I2Rest_Server#basic_guide|basic guide]], so let's proceed updating i2Rest Server [[I2Rest_Config|configuration]] on the way to the full functional server instance.<br>
| |
− | =SSL=
| |
− | The first thing we recommend to add to the [[I2Rest_quick_config|basic server configuration]] is a https protocol connections protection. Please follow [[I2Rest_secured_gate|ssl guide]].
| |
| | | |
− | =Request authorization=
| + | * [[Using secured connections]] |
− | Most of requests to i2Rest Sever require authorization. Such requests as [[I2Rest_API#run_command_API|IBM i command call]], [[I2Rest_API#run_program_API|API call]] (except anonymous API call) and [[I2Rest_API#Management_APIs|Мanagement api call]] without Oauth2 token with appropriate [[I2Rest_scopes|scope]] will not be served. Let's observe [[OAuth2_object#Settings_for_built-in_implementation|i2Rest built-in authorization model]] configuration options on example.<br>
| + | * [[i2Rest Gate URL definition using Unix socket|Serving incoming connections using Unix sockets]] |
− | <div id="Oauth2_obj_template">
| + | * [[I2Rest_with_syslog|Using syslog with i2Rest Server]] |
− | "OAuth2":
| + | * [[Configuring OAuth2 authorization]] |
− | {
| + | * [[Run_command_Api_config|How to allow calls to run_command API]] |
− | "scopes": {"management_functions" : {"description":"Invoke i2Rest manager APIs"}},
| + | * [[Management_API_config|How to allow calls to management API]] |
− | "users":
| + | * [[Remote_API_call_config|How to call API located on remote IBM i server]] |
− | {
| + | * [[I2Rest_Basic_PowerApps_Connector|How to create Microsoft Power Apps custom adapter to i2Rest Server]] |
− | "<span style="color:red;">USRX</span>":{"description":"<span style="color:red;">John Johnes</span>","valid_clients":{"<span style="color:red;">TSTCLNT</span>":{"scopes":["management_functions"]}}}
| + | i2Rest server should be [[I2Rest_Start|restarted]] to aplly your new configuration *.json. |
− | },
| |
− | "clients":
| |
− | {
| |
− | "<span style="color:red;">TSTCLNT</span>":{"redirect_uri":"<span style="color:red;"><main gate URL></span>/oauth2/redirect",
| |
− | "description":"Test client",
| |
− | "valid_scopes":["management_functions"],
| |
− | "valid_grant_types":["authorization_code"]}
| |
− | },
| |
− | "tokens": {"type":"token"},"codes":{"type":"code"}
| |
− | }
| |
− | <div>
| |
− | The snippet above shows us [[OAuth2_object|OAuth2 object]], representing built-in authorization model. In general worlds i2Rest authorization model is something like '''WHAT''' is allowed and to '''WHOM''', and '''HOW''' it realized. '''WHAT''' parameters - are the "scopes", '''HOW''' parameters - "tokens", '''WHOM''' parameters - "users" and "clients" (built-in authorization model implies that both "users" and "clients" has to be registered as an IBM i users). So we can see that user '''USRX''' using client '''TSTCLNT''' is allowed to do some actions within '''"managment_functions"''' scope. And these are exactly the settings of Oauth2 object that we need to perform a Мanagement api call.<br>
| |
− | | |
− | ==Мanagement API call==
| |
− | So, what you have to do before we can test Мanagement API call to i2Rest Server:
| |
− | :a) Register two users on IBM i - one for a "сlient" parameter and one for a "user" parameter.
| |
− | :b) Fill the [[I2Rest_Advanced_Setup#Oauth2_obj_template|OAuth2 object template]] above with IBM i users values. Then add the snippet to your [[I2Rest_quick_config|basic server configuration]](with or without ssl protection) and put your new *.json anywhere on IBM i IFS.
| |
− | :c) Restart sever to apply your new configuration *.json.
| |
− | Now let's test the configuration obtaining [[Auth_profile_SoapUI|Oauth2 token with Soap UI]], and than proceed to [[Manage_API_SoapUI|Management api authorized call]].
| |
− | | |
− | == run_program API call==
| |
− | Unlike anonimous API call we performed in our [[I2Rest_Server#basic_guide|basic guide]], authorized API call requires Oauth2 token with [[I2Rest_scopes#run_program|"run_program" scope]] and <code>*local</code> [[I2Rest_Gates#Session_System|Session System defined]].
| |
− | So that's how we will change your [[I2Rest_quick_config|basic server configuration]](with or without ssl protection) to perform authorized run_program API call:
| |
− | :a)add the snippet bellow to the [[Session_system_object|session systems object]]:
| |
− | <pre>{
| |
− | "name": "*LOCAL",
| |
− | "submit": SBMJOB JOB(I2RESTS) USER(${user})
| |
− | CMD(CALL I2REST PARM(
| |
− | '-session'
| |
− | '-url' '${surl}'
| |
− | '-uid' '${uid}'
| |
− | '-user' '${user}'
| |
− | '-init' 'ADDLIBLE I2REST'))
| |
− | '-dcm_client_id' 'MYCLIENT'))"
| |
− | },
| |
− | </pre>
| |
− | :b)Register two users on IBM i - one for a "сlient" parameter and one for a "user" parameter.
| |
− | :c)Fill the [[I2Rest_Advanced_Setup#Oauth2_obj_template|OAuth2 object template]] above with IBM i users values and add to your *.json
| |
− | :d)add the "run_program" scope to scopes object
| |
− | :e)change the pscms object as follows:
| |
− | "pcmls":
| |
− | [
| |
− | {
| |
− | "pcml_mount" : "echo",
| |
− | "pcml_file" : "<complete name of i2restecho.pcml on IFS (for example /tmp/PCML/i2restecho.pcml)>",
| |
− | "valid_in_anonymous" : <span style="color:red;">false</span>
| |
− | }
| |
− | ]
| |
− | :f)Restart sever to apply your new configuration *.json.
| |
− | Now you can update your [[I2Rest_Basic_Test#SOAP_UI|SoapUI ECHO test project]] with [[Auth_profile_SoapUI|Authorization profile]] and perform your authorized API call.
| |