Changes for page Community App Developer Guide
Last modified by bougault on 2022/03/02 11:58
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. mmorgan1 +XWiki.allan - Content
-
... ... @@ -4,83 +4,217 @@ 4 4 5 5 == Becoming a contributor == 6 6 7 -The first step is for you to **get the developer accreditation**. Contributors can register and manage apps within the Community Apps Catalogue. 7 +The first step is for you to **get the developer accreditation**. Contributors can register and manage applications within the Community Apps Catalogue. 8 8 9 -Send an email to [[support@ ebrains.eu>>mailto:support@ebrains.eu]] with a short motivationforyourrequest.9 +Send an email to [[support@humanbrainproject.eu>>mailto:support@humanbrainproject.eu]] with a short summary of your intentions. 10 10 11 -The support team will apply the permissions to your user .Your account will be[[upgraded with developer privileges>>doc:Collabs.collab-devs.collaboratory-v2.keycloak.useradministration.WebHome]] the next time you login.11 +The support team will apply the permissions to your user: your account will be upgraded with developers privileges the next time you will login. 12 12 13 13 (% class="box infomessage" %) 14 14 ((( 15 -Only SGA 3accredited users will be automatically granted the developer accreditation.15 +Only SGA2 accredited users will be automatically granted the developer accreditation. 16 16 ))) 17 17 18 +(% class="wikigeneratedid" %) 18 18 == Making your app available to users == 19 19 20 -In serstoourapp,21 +In order for you application to be installable by users, it needs to be registered within the [[Community Apps Catalogue>>doc:Apps.WebHome]]. 21 21 22 - Ifyouaredealingwithprivatedata,or your usersneedtobe authenticated,see [[authenticationand authorizationin the Collaboratory.>>doc:Collabs.the-collaboratory.Technicaldocumentation.Architecture.Permissions.Authentication & Authorisation using OIDC.WebHome]]23 +Once this simple step is complete, users will be able to install your app within their collabs. 23 23 24 24 === Registering an application in the Catalogue === 25 25 26 -Navigate 27 +Navigate to the catalogue and click on **+Create App** in the top right corner. Enter a name for your app and click on **Create**. 27 27 28 -Fill 29 +Fill the form with the following information: 29 29 30 -* **main theuserswill be directed when theyopen your app in a collab.31 -* **settings app'ssettings,ifthere isone.32 -* **description**: . This helpsuserschoosetheappstheyinstall.33 -* **under ifchecked,yourwill notother34 -* **category**: ethestf apps.35 -* **maintainers**: appearonthe list.theapp'sregistration.36 -* **documentation 37 -* **repository**: accessthecode of31 +* **main URL**: the URL of the homepage of your app. This is where user will be directed when then open your app in a collab. 32 +* **settings URL**: the URL of the your settings management page if you have one. 33 +* **description**: a description of what your app does to help users select it. 34 +* **under development?**: should be checked if you don't want your app to be available by default by other users. 35 +* **category**: a category to help structuring the applications. 36 +* **maintainers**: a list of users who maintain the app. The users need to have logged in the wiki at least once to be found. Maintainers are granted the right to modify an app registration. 37 +* **documentation URL**: if your app has online user documentation, a link will be provided to users when they use your app. 38 +* **repository**: a URL to a public repository so users can check the sources of your app. 38 38 39 -Click 40 +Click on **Save**. Your app is now registered and waiting for users to install it! 40 40 41 -=== Installing 42 +=== Installing your app in a collab === 42 42 43 -1. In order to install your app, you need to navigate 44 -1. Click at the top right to create a new entry in the navigation pane under the current wiki page.45 -1. Click syoufor whichyouarea46 -1. Select 44 +1. In order to install your app, you need to navigate to a collab where you have either the **editor** or **administrator** role. 45 +1. Click on **Create**. Enter a title for this instance of your app and select **Community App** in the right selector. 46 +1. Click on **Create**. You will be presented with the Community App Catalogue. The app you will see are the public apps and the ones your a maintainer of. 47 +1. Select your app and click on **Save and View**. 47 47 48 -You in your collab just as other userswillsee it.49 +You should now see how your app looks like within a collab. 49 49 50 -== Getting yourappinstance context==51 +== Creating your OpenID Connect client == 51 51 52 - Instances ofyourapps will beinstalledby collab ownersin many different collabs.Inordertolet youcustomiseheuserxperiencebased on its context, theCollaboratorywill automatically pass query parameters to your app:53 +The steps to create an OpenID Connect client are the following: 53 53 54 -* **##clb-collab-id##**: the unique, human-readable identifier of the collab. 55 -* ##**clb-doc-path**##: the (relative) path to your app instance within the collab. If your app is at the root of a collab, this value will be empty. 56 -* ##**clb-doc-name**##: the name of the document where your app instance is installed. 57 -* ##**clb-drive-id**##: the unique identifier of the drive of the collab. This id is required if you want to fetch or store documents within the drive of the collab. 55 +1. get an access token from the `developer` client 56 +1. use the token to call the create endpoint 57 +1. save your registration access token for further modifications of your client 58 58 59 -== App settings ==59 +=== Fetching your developer access token === 60 60 61 - Theapp settingsarethealuesthecollabownerscanmodifytochange thebehaviourofyour appwithintheircollabs.61 +Getting your developer token is done in one simple step: authenticate against the developer client with the password grant. 62 62 63 - === Writingsettings===63 +This can be achieved with this sample shell script: 64 64 65 -The Collaboratory comes with a mechanism to let your app store its settings directly in the Collaboratory. 65 +{{code language="bash"}} 66 +# Gather username and password from user 67 +echo '\nEnter your username' && read clb_dev_username && 68 +echo '\nEnter your password' && read -s clb_dev_pwd && 66 66 67 -In order to do that, your app needs to use the [[postMessage javascript API>>https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage]] to send the settings to be stored in the Collaboratory. The settings are key/value pairs as in the example below. 70 +# Fetch the token 71 +curl -X POST https://iam.humanbrainproject.eu/auth/realms/hbp/protocol/openid-connect/token \ 72 + -u developer: \ 73 + -d 'grant_type=password' \ 74 + -d "username=${clb_dev_username}" \ 75 + -d "password=${clb_dev_pwd}" | 76 + 77 +# Prettify the JSON response 78 +json_pp; 68 68 69 -{{code language="javascript"}} 70 -window.parent.postMessage({ 71 - topic: '/clb/community-app/settings', 72 - data: { 73 - setting1: 'setting 1 value', 74 - setting2: 'setting 2 value', 75 - // ... 76 - // reload: false // avoid page reload on settings change 77 - }}, 'https://wiki.ebrains.eu'); 80 +# Erase the credentials from local variables 81 +clb_dev_pwd='';clb_dev_username='' 78 78 {{/code}} 79 79 80 - ===Readingsettings===84 +The response will be similar to: 81 81 82 -The Collaboratory will get the settings from its key/value store and pass them to your app through query parameters. 86 +{{code language="json"}} 87 +{ 88 + "access_token": "eyJhbGci...", 89 + "expires_in": 108000, 90 + "refresh_expires_in": 14400, 91 + "refresh_token": "eyJhbGci...", 92 + "token_type": "bearer", 93 + "not-before-policy": 1563261088, 94 + "session_state": "0ac3dfcd-aa5e-42eb-b333-2f73496b81f8", 95 + "scope": "" 96 +} 97 +{{/code}} 83 83 84 - ==CreatingyourOpenIDConnectclient==99 +Copy the "access_token" value, you will need if for the next step. 85 85 86 -See the instructions [[here>>doc:Collabs.collaboratory-community-apps.Community App Developer Guide.1\. Registering an OIDC client.WebHome]]. 101 +=== Creating the client === 102 + 103 +You can now create clients by sending a JSON representation to a specific endpoint: 104 + 105 +{{code language="bash"}} 106 +# Set your developer token 107 +clb_dev_token=... 108 + 109 +# Send the creation request 110 +curl -X POST https://iam.humanbrainproject.eu/auth/realms/hbp/clients-registrations/default/ \ 111 + -H "Authorization: Bearer ${clb_dev_token}" \ 112 + -H 'Content-Type: application/json' \ 113 + -d '{ 114 + "clientId": "my-awesome-client", 115 + "name": "My Awesome App", 116 + "description": "This describes what my app is for end users", 117 + "rootUrl": "https://root.url.of.my.app", 118 + "baseUrl": "/relative/path/to/its/frontpage.html", 119 + "redirectUris": [ 120 + "/relative/redirect/path", 121 + "/these/can/use/wildcards/*" 122 + ], 123 + "webOrigins": ["+"], 124 + "bearerOnly": false, 125 + "consentRequired": true, 126 + "standardFlowEnabled": true, 127 + "implicitFlowEnabled": true, 128 + "directAccessGrantsEnabled": false, 129 + "attributes": { 130 + "contacts": "first.contact@example.com; second.contact@example.com" 131 + } 132 + }' | 133 + 134 +# Prettify the JSON response 135 +json_pp; 136 +{{/code}} 137 + 138 +In case of success, the endpoint will return its representation of your client: 139 + 140 +{{code language="json"}} 141 +{ 142 + "defaultClientScopes" : [ 143 + "web-origins", 144 + "roles" 145 + ], 146 + "redirectUris" : [ 147 + "/relative/redirect/path", 148 + "/these/can/use/wildcards/*" 149 + ], 150 + "nodeReRegistrationTimeout" : -1, 151 + "rootUrl" : "https://root.url.of.my.app", 152 + "webOrigins" : [ 153 + "+" 154 + ], 155 + "authenticationFlowBindingOverrides" : {}, 156 + "baseUrl" : "/relative/path/to/its/frontpage.html", 157 + "description" : "This describes what my app is for end users", 158 + "notBefore" : 0, 159 + "frontchannelLogout" : false, 160 + "enabled" : true, 161 + "registrationAccessToken" : "eyJhbGciOi...", 162 + "consentRequired" : true, 163 + "fullScopeAllowed" : false, 164 + "clientAuthenticatorType" : "client-secret", 165 + "surrogateAuthRequired" : false, 166 + "directAccessGrantsEnabled" : false, 167 + "standardFlowEnabled" : true, 168 + "id" : "551b49a0-ec69-41af-9461-6c10fbc79a35", 169 + "attributes" : { 170 + "contacts" : "first.contact@example.com; second.contact@example.com" 171 + }, 172 + "name" : "My Awesome App", 173 + "secret" : "your-client-secret", 174 + "publicClient" : false, 175 + "clientId" : "my-awesome-client", 176 + "optionalClientScopes" : [], 177 + "implicitFlowEnabled" : true, 178 + "protocol" : "openid-connect", 179 + "bearerOnly" : false, 180 + "serviceAccountsEnabled" : false 181 +} 182 +{{/code}} 183 + 184 +Among all the attributes, you should securely save: 185 + 186 +* your client **secret** ("secret" attribute): it is needed by your application to **authenticate to the IAM server** when making backend calls 187 +* your client **registration access token** ("registrationAccessToken"): you will need it to authenticate when **modifying your client in the future** 188 + 189 +=== Modifying your client === 190 + 191 +Update your client with a PUT request: 192 + 193 +{{code language="bash"}} 194 +# Set your registration token and client id 195 +clb_reg_token=... 196 + 197 +# Update the client 198 +curl -X PUT https://iam.humanbrainproject.eu/auth/realms/hbp/clients-registrations/default/my-awesome-client \ 199 + -H "Authorization: Bearer ${clb_reg_token}" \ 200 + -H 'Content-Type: application/json' \ 201 + -d '{ 202 + "clientId": "my-awesome-client", 203 + "redirectUris": [ 204 + "/relative/redirect/path", 205 + "/these/can/use/wildcards/*", 206 + "/a/new/redirect/uri" 207 + ] 208 + }' | 209 + 210 +# Prettify the JSON response 211 +json_pp; 212 +{{/code}} 213 + 214 + Note that your need to provide your client id both in the endpoint URL and within the body of the request. 215 + 216 +{{warning}} 217 +/!\ ** Each time you modify your client, a new registration access token will be generated. You need to track of your token changes to keep access to your client. **/!\ 218 +{{/warning}} 219 + 220 +== ==