microsoft / microsoft/pai

Sub-path deployment support.

Open
#5,469 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
554
Avg merge
20h 42m
Merged PRs (30d)
14

Description

What would you like to be added: Sub-path deployment support.

Why is this needed: Domain names are limited, and multiple apps need to reuse the same domain name through sub-paths.

Without this feature, how does the current module work:

For now, deploying openpai to the sub-path according to this issue, everything seems to be working well.

However, when the root path contains the cookie named user, token, admin (or any of them), the login or authentication of openpai will be problematic.

openpai uses the js-cookie plug-in to manage cookies. The plug-in can specify a path to isolate cookies when adding cookies to reduce conflicts.

By analyzing the browser cache, I got the following solution for v1.6.0.

Add these lines in openpai location block.

        sub_filter '{expires:7}' '{expires:7, path: ""}';
        sub_filter '{expires:h}' '{expires:h, path: ""}';
        sub_filter 'remove("token")' 'remove("token", {path: ""})';

However, because the JavaScript source code is compressed when it is released, this solution cannot be applied to any other version.

Therefore, a deterministic solution is necessary.

Components that may involve changes:

According to the js-cookie document, we only need to modify the following lines.

conn.js

    cookies.set('user', loginInfo.user, { expires });
    cookies.set('token', loginInfo.token, { expires });
    cookies.set('admin', loginInfo.admin, { expires });

index.jsx

    cookies.set('user', query.get('user'), { expires: expiration });
    cookies.set('token', query.get('token'), { expires: expiration });
    cookies.set('admin', query.get('admin'), { expires: expiration });

user-logout.component.js

  cookies.remove('user');
  cookies.remove('token');
  cookies.remove('admin');

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/webportal/src/app/home/index/conn.js, src/webportal/src/app/home/index.jsx, and src/webportal/src/app/user/user-logout/user-logout.component.js, then review how js-cookie handles path options. Verify that login, authentication, and logout work when OpenPAI is deployed under a sub-path without conflicting with root cookies.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.