====== Vibemosphere Azure Application Management ====== Azure / Microsoft Entra applications: client secret, certificate (CA plug-in) or delegated sign-in, mailboxes, SharePoint and OneDrive URLs, profile tests, token cache and expiry dates. ^ Id | ''aam'' | ^ Role | ''aam'' - needed for the page and the REST API (administrators always may) | ^ Page | **Plugins > Open** (overlay with an X at the top right) or ''/plugins/aam/'' | ^ REST | ''/api/plugins/aam/...'' and, for callers with the role, ''/plugins/aam/...'' | ===== Open the configuration ===== In the administration open **Plugins**, select the row of this plug-in and press **Open**. The page opens in an overlay dialog: close it with the **X** at the top right, with Esc or by clicking outside; //Open in a new tab// next to the title shows it full size. {{vibecat:plugin-aam.png?900|Vibemosphere Azure Application Management: the plug-in page in its overlay dialog}} ===== Step by step ===== - Create the application in your tenant (Entra ID > App registrations) and note the **Tenant ID** and **Application (client) ID**. - Choose how Vibecat authenticates: **client secret**, **certificate** (issued by the [[vibecat:plugins:ca|CA plug-in]] or imported as PFX) or **delegated sign-in** (device code). - Give the application the permissions the profiles need (for example ''Mail.Send'', ''Mail.ReadWrite'', ''Sites.ReadWrite.All'') and grant admin consent. - Add the mailboxes, SharePoint site URLs and OneDrive URLs that belong to the application. - Run the **profile tests** (mail sender, mail archiver, SharePoint reader/writer, OneDrive reader/writer) and watch the expiry dates of secrets, certificates and cached tokens. ===== The page in detail ===== {{vibecat:plugin-aam-full.png?900|Vibemosphere Azure Application Management: the whole page (playground instance)}} The page has these sections: **Application**, **Certificate**, **Issue with the CA plug-in**, **Import a PFX**, **Sign in**, **Test**. ==== Dialog: New application ==== {{vibecat:plugin-aam-dialog.png?900|Vibemosphere Azure Application Management: the dialog of "New application"}} ===== Fields and columns ===== ^ Label ^ Meaning ^ | Name | | | Authentication | | | Client / application id | | | Tenant id | | | Client secret | | | Secret valid until | | | Mailboxes (one per line; mail sender and archiver) | | | SharePoint site URLs | | | OneDrive URLs or user principal names | | | Notes | | | Certificate authority | | | Valid days | | | PFX file | | | Password | | | Targets (one per line, from the registered ones) | | | Recipient of the test mail | | | Library for the write test | | | Signed-in account | | ===== Actions ===== * **New application** * **Reload** * **Cancel** * **Save** * **Issue new certificate** * **Import** * **Download .cer (public part)** * **Remove certificate** * **Close** * **Start sign-in** * **Copy code** * **Run test** ===== Notes from the page ===== * A new key pair; upload the .cer to the application in the Azure portal (Certificates & secrets). * The sign-in uses the device code: you get a code and open Microsoft's page on any device, sign in and agree. The refresh token is cached (encrypted) and used again, so this is needed once per account. * Waiting for the sign-in ... ===== Reference ===== Keeps the Azure / Microsoft Entra applications that Vibecat and the programs around it use to reach Microsoft 365: how an application signs in, which mailboxes, SharePoint sites and OneDrive locations it is meant for, whether it works (profile tests) and **when something runs out**. ==== How an application signs in ==== ^ Mode ^ What you enter ^ Notes ^ | **Client secret** | Client id, tenant id, secret, //valid until// | Application permissions (client credentials). SharePoint Online refuses app-only tokens with a secret: use a certificate for SharePoint. | | **Certificate** | Client id, tenant id; the certificate is **issued by the CA plug-in** (type client, any valid days) or imported as PFX | A signed client assertion (RS256, ''x5t#S256'') is sent, no secret. Download the **.cer** (public part) and upload it to the application in the Azure portal under //Certificates & secrets//. The private key stays here (encrypted). | | **Delegated** | Optionally client id / tenant id; then **Sign in (Microsoft 365)** | The device code login: a code and a link; sign in with the account once. The refresh token is cached (encrypted) and renewed with every use (about 90 days of non-use). Leave the client id empty for the **applicationless** way: the public client of Microsoft Graph PowerShell (''14d82eec-204b-4c2f-b7e8-296a70dab67e'') is used, no own registration; the user agrees to the permissions at the sign-in. An own application must allow //public client flows// (or have a secret / certificate here, which is then sent as well). | ==== Registered targets ==== The mailboxes, SharePoint site URLs and OneDrive URLs (or user principal names) are stored **with the application**. The profile tests use them (and the dialog lets you change the list for one run). ==== Profile tests ==== ^ Profile ^ What it does ^ | Mail sender (''Mail.Send'') | Token and permission check. Optional: really sends a test mail from every sender mailbox to a recipient. | | Mail archiver (''Mail.ReadWrite'') | Reads the inbox of every mailbox. Optional write test: a draft is created and deleted. | | SharePoint CSOM reader | Token for the SharePoint host (''https:///.default''), a CSOM ''ProcessQuery'' reads the web (title, URL). | | SharePoint CSOM writer | The read test, then a small file is uploaded to a library (default //Shared Documents//) and deleted. | | OneDrive Graph reader | Resolves a OneDrive URL (''/shares/u!...'') or the drive of a user and lists a few entries. | | OneDrive Graph writer | The read test, then a small file is uploaded to the folder and deleted. | A read test never changes anything. A write test says so before it runs, creates one small test object and deletes it at once. The result of the last run of each profile is shown on the button. ==== Valid until ==== Each application shows: the **certificate** (not after), the **client secret** (the date you enter, or read from Azure), every cached **sign-in** (refresh token, about 90 days after the last use) and the **access tokens** that are cached in memory right now. Less than 30 days is marked //soon//. **Azure check** reads the secrets and certificates of the application from Azure (Microsoft Graph ''applications'', permission ''Application.Read.All'' with admin consent), sets the secret date from it and tells whether the certificate of this plug-in is registered there. ==== Tokens for other plug-ins and programs ==== POST /api/plugins/aam/token {"app": "my-app", "resource": "graph"} // or "sharepoint:contoso.sharepoint.com", or a scope {"app": "my-app", "resource": "graph", "account": "jane@contoso.com"} // delegated applications => {"accessToken": "...", "tokenType": "Bearer", "expiresOn": "...", "expiresIn": 3541} Inside Vibecat another plug-in calls ''context.callPlugin("aam", "POST", "/token", null, json)''. Access tokens are cached until two minutes before they run out. ==== Security ==== * Secrets, PFX files and refresh tokens are stored AES-GCM encrypted in ''apps.json''; the key is ''master.key'' next to it (data folder of the plug-in). **Keep and back up the data folder as one; keep it private.** * The pages and the API need the administration login (the role ''aam'' or admin). Secrets are never sent to the page. * Sovereign clouds: set ''AAM_LOGIN_BASE'' (for example ''https://login.microsoftonline.us''). ==== API ==== ''GET /state'', ''GET|POST /apps'', ''GET|PUT|DELETE /apps/{id}'', ''POST|GET|DELETE /apps/{id}/certificate'', ''POST /apps/{id}/certificate/import'' (''pfx'' base64, ''password''), ''POST /apps/{id}/login'', ''GET /apps/{id}/login/{flow}'', ''DELETE /apps/{id}/accounts/{user}'', ''POST /apps/{id}/test'' (''profile'', ''targets'', ''write'', ''send'', ''recipient'', ''library'', ''account''), ''POST /apps/{id}/azure-info'', ''POST /apps/{id}/forget'', ''POST /token''. [[vibecat:plugins:start|All plug-ins]]