mehdimiah_
07/25/2024, 11:48 AMSebastiaan
07/25/2024, 12:00 PMmehdimiah_
07/25/2024, 12:00 PMSebastiaan
07/25/2024, 12:00 PMmehdimiah_
07/25/2024, 12:01 PMmehdimiah_
07/25/2024, 12:02 PMSebastiaan
07/25/2024, 12:03 PMmehdimiah_
07/25/2024, 1:33 PMAnders Bjerner
07/25/2024, 1:53 PMcsharp
return Json(data);
Given that your controller extends ASP.NET's Controller
class, you'll have acces to a bunch of different methods - with the Json
method being one of them.mehdimiah_
07/25/2024, 2:05 PMmehdimiah_
07/25/2024, 3:41 PMmehdimiah_
07/25/2024, 3:41 PMSebastiaan
07/25/2024, 3:45 PM/umbraco
route. But I really don't know a lot about auth https://github.com/nul800sebastiaan/Cultiv.Hangfire/blob/bellissima/Cultiv.Hangfire/UmbracoBuilderExtensions.cs#L39Sebastiaan
07/25/2024, 3:45 PMmehdimiah_
07/25/2024, 3:46 PMSebastiaan
07/25/2024, 3:46 PMmehdimiah_
07/25/2024, 3:46 PMSebastiaan
07/25/2024, 3:47 PMmehdimiah_
07/25/2024, 3:48 PMAnders Bjerner
07/25/2024, 4:19 PMUmbracoAuthorizedApiController
class, and then users would only be able to access your controller if already authenticated with the backoffice. The authentication was cookie based, so you didn't need to pass any extra parameters for the authentication to work.
Umbraco 14 instead uses OAuth 2.0 for authentication, meaning you should sent a bearer token via the Authorization
header for each request. Umbraco 14 has also dropped support for UmbracoApiController
and UmbracoAuthorizedApiController
, so you can instead extend ASP.NET's Controller
class directly instead. I haven't read up on all the authentication options, but say your controller should only be accessible to backoffice users with access to the content section, you can add this attribute to the controller:
https://github.com/skybrud/Skybrud.Umbraco.Redirects/blob/v14/main/src/Skybrud.Umbraco.Redirects/Controllers/Api/BackOffice/RedirectsController.cs#L31
The frontend for the backoffice would then have to obtain the bearer token and pass it on to the controller. I don't think the logic around this is documented though - or I just didn't manage to find it. Bu you're welcome to peak a bit around in my code for inspiration:
https://github.com/skybrud/Skybrud.Umbraco.Redirects/blob/v14/main/src/Skybrud.Umbraco.Redirects/wwwroot/EntryPoint.js#L9-L12
https://github.com/skybrud/Skybrud.Umbraco.Redirects/blob/v14/main/src/Skybrud.Umbraco.Redirects/wwwroot/RedirectsAuth.js
https://github.com/skybrud/Skybrud.Umbraco.Redirects/blob/v14/main/src/Skybrud.Umbraco.Redirects/wwwroot/RedirectsService.js
It is however worth mentioning that (at least for now) I have opted to use Vanilla JS, although Umbraco recommends using TypeScript. So there might be better examples out there somewhere.mehdimiah_
07/26/2024, 8:42 AMbiapar
09/11/2024, 2:56 PM