question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing content in a headless manner

See original GitHub issue
  1. Added the package Piranha.WebApi
  2. added options.UseApi();
  3. I created a page called home with the same slug
  4. Using PostMan REST Client, accessing https://localhost:44305/api/page/GetBySlug?slug=home (might be issue here)
  5. Getting 401 error Unauthorized
  6. I tried sending Basic Authentication with it using admin/pass, still same issue

I have the /manager accessible by admin/password so I assume that is what is needed to be sent, the default identity is IdentitySqlLiteDb if it matters.

I looked at the code for the .WebApi package and it seems to fail at the following.

        [HttpGet]
        [Route("{slug}")]
        public async Task<IActionResult> GetBySlug(string slug)
        {
            if (!Module.AllowAnonymousAccess)
            {
                if (!(await _auth.AuthorizeAsync(User, Permissions.Pages)).Succeeded)
                {
                    return Unauthorized();
                }
            }
            return Json(await _api.Pages.GetBySlugAsync<PageBase>(slug));
        }

How do I configure this specific module so that Anonymous access is allowed and not even ask/require credentials?

I am simply trying to have a cms where I can enter content through /manager and then be able to access all created pages using the api (hopefully) without even any type of authentication.

I understand I can role my own API and remove the checks where it asks for creds but I would like to understand the process better and even prefer to use the built in provided by you guys.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tidyuicommented, Oct 12, 2020

The correct syntax for calling that endpoint would be

https://localhost:44305/api/page/home
0reactions
biaparcommented, Aug 13, 2021
  1. Added the package Piranha.WebApi
  2. added options.UseApi();
  3. I created a page called home with the same slug
  4. Using PostMan REST Client, accessing https://localhost:44305/api/page/GetBySlug?slug=home (might be issue here)
  5. Getting 401 error Unauthorized
  6. I tried sending Basic Authentication with it using admin/pass, still same issue

I have the /manager accessible by admin/password so I assume that is what is needed to be sent, the default identity is IdentitySqlLiteDb if it matters.

I looked at the code for the .WebApi package and it seems to fail at the following.

        [HttpGet]
        [Route("{slug}")]
        public async Task<IActionResult> GetBySlug(string slug)
        {
            if (!Module.AllowAnonymousAccess)
            {
                if (!(await _auth.AuthorizeAsync(User, Permissions.Pages)).Succeeded)
                {
                    return Unauthorized();
                }
            }
            return Json(await _api.Pages.GetBySlugAsync<PageBase>(slug));
        }

How do I configure this specific module so that Anonymous access is allowed and not even ask/require credentials?

I am simply trying to have a cms where I can enter content through /manager and then be able to access all created pages using the api (hopefully) without even any type of authentication.

I understand I can role my own API and remove the checks where it asks for creds but I would like to understand the process better and even prefer to use the built in provided by you guys.

See this to: https://gist.github.com/biapar/e48bb57e86759c9ffb14fdabbf804369

Read more comments on GitHub >

github_iconTop Results From Across the Web

Headless CMS 101: The Only Guide You'll Ever Need
The content stored in the headless CMS is accessed via a set of APIs that developers can use to present the data wherever...
Read more >
A headless content management system (CMS) is ...
A headless CMS means that the content layer is decoupled or disconnected from the presentation layer. The content layer is where all the...
Read more >
What is a Headless CMS?
Simply put, a headless CMS is a content management system that manages and organizes content without a connected front-end or display layer. The...
Read more >
Everything You Need to Know About Headless CMS
With headless CMS, content can be easily reused across multiple channels, including websites, mobile apps, digital kiosks, and smart devices.
Read more >
Losing our Heads for Better Content Management
A “headless” or “decoupled” CMS is a Content Management System that focuses solely on a content authoring, curation, and publishing workflow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found