<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15329</bug_id>
          
          <creation_ts>2023-12-19 20:48:35 +0000</creation_ts>
          <short_desc>Default https://localhost:8081/accounts/login throws a 403 error; CSRF_TRUSTED_ORIGINS needs the port appended</short_desc>
          <delta_ts>2026-05-14 14:57:39 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>Layer Index</product>
          <component>Layer Index</component>
          <version>5.0</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.1 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Orling">tim.orling</reporter>
          <assigned_to name="Tim Orling">tim.orling</assigned_to>
          <cc>piotr</cc>
    
    <cc>randy.macleod</cc>
          
          <qa_contact name="apoorv sangal">apoorvsangal</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97626</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-19 20:48:35 +0000</bug_when>
    <thetext>With the introduction of CSRF_TRUSTED_ORIGINS in Django 4.2, a default &apos;dockersetup.py&apos; installation will set the port to 8081 and the hostname will be localhost.

When logging in, this will result in a 403 error:
Origin checking failed - https://localhost:8081 does not match any trusted origins.

In order for this combination to work, 
CSRF_TRUSTED_ORIGINS = [&apos;https://&apos; + os.getenv(&apos;HOSTNAME&apos;, &apos;layers.test&apos;), &apos;https://localhost:8081&apos;]
would have to be the setting.

The fix should be in making the dockersetup.py script smart enough to append the port conditionally if it is not the default 80 or 443.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100941</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2025-02-13 16:05:16 +0000</bug_when>
    <thetext>Michael, is this something you can do on the systems that run the layer index?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100942</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Halstead">mhalstead</who>
    <bug_when>2025-02-13 18:49:23 +0000</bug_when>
    <thetext>As far as I understand this issue is not a problem for production deployments including the main one at layers.openembedded.org. I can have a look next time I set up a test instance but I hope a developer beats me to it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104418</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2026-02-26 16:09:38 +0000</bug_when>
    <thetext>We&apos;re likely moving away from the dockersetup.py script to .env files and docker-compose. I think the .devcontainer work by Piotr completely avoids this particular problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104555</commentid>
    <comment_count>4</comment_count>
    <who name="Piotr Buliński">piotr</who>
    <bug_when>2026-03-06 18:22:22 +0000</bug_when>
    <thetext>This does not seem to be a problem with the current Dev Container setup and shouldn&apos;t be a problem if deployed using docker/settings.py, as this property is derived from HOSTNAME env variable (with backwards compatible default).

When using default, out-of-the-box setup for Dev Container, log in works without any issues.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>