Repository navigation
feat: Shibbolethログイン用スクリプトをlogin.phpからlogin.pyに置き換え #1944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mhaya
wants to merge
1
commit into
fix/63224
Choose a base branch
from
feature/jgss_login_py
base: fix/63224
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/python3 | ||
| import json | ||
| import os | ||
| from urllib import parse | ||
|
|
||
| import requests | ||
| import urllib3 | ||
| from urllib3.exceptions import InsecureRequestWarning | ||
| urllib3.disable_warnings(InsecureRequestWarning) | ||
|
|
||
| # Set the base URL | ||
| base_url = os.environ.get('REQUEST_SCHEME', 'https') + '://' \ | ||
| + os.environ.get('SERVER_NAME', '') | ||
| if not os.environ.get('HTTP_WEKOSOCIETYAFFILIATION') \ | ||
| and os.environ.get('NO_CHECK_WEKOSOCIETYAFFILIATION') != 'TRUE': | ||
| # Alert and redirect to the base URL if the permission is invalid | ||
| print('Content-Type: text/html; charset=utf-8') | ||
| print('') | ||
| print('<script type="text/javascript">' | ||
| 'window.alert("Permission is invalid");' | ||
| 'window.location.href={};</script>'.format(json.dumps(base_url))) | ||
| else: | ||
| # Get the next URL | ||
| qs = parse.parse_qs(os.environ.get('QUERY_STRING', '')) | ||
| next_url = qs['next'][0] if 'next' in qs else '/' | ||
| url = base_url + '/weko/shib/login?next=' + parse.quote(next_url, safe='') | ||
|
|
||
| # Create the form data in the same format as login.php | ||
| data = { | ||
| 'SHIB_ATTR_USER_NAME': os.environ.get('HTTP_WEKOID', ''), | ||
| 'SHIB_ATTR_EPPN': os.environ.get('Remote-User', ''), | ||
| 'SHIB_ATTR_MAIL': os.environ.get('mail', ''), | ||
| 'SHIB_ATTR_SESSION_ID': os.environ.get('Shib-Session-ID', ''), | ||
| 'SHIB_ATTR_ROLE_AUTHORITY_NAME': | ||
| os.environ.get('HTTP_WEKOSOCIETYAFFILIATION', ''), | ||
| } | ||
|
|
||
| # Request to the Shibboleth login | ||
| response = requests.post(url, data=data, verify=False) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (python.requests.security.disabled-cert-validation): Certificate verification has been explicitly disabled. This permits insecure connections to insecure servers. Re-enable certification validation. Source: opengrep |
||
| response.raise_for_status() | ||
| redirect = response.text | ||
|
|
||
| if redirect.startswith('/'): | ||
| # Redirect to the Shibboleth login | ||
| print('Status: 302 Found') | ||
| print('Content-Type: text/html') | ||
| print('Location: ' + base_url + redirect) | ||
| print('') | ||
| else: | ||
| # Display the login page or the page before login processing | ||
| print('Status: 200 OK') | ||
| print('Content-Type: text/html; charset=utf-8') | ||
| print('') | ||
| print(redirect) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High · Backend TLS can be impersonated
When traffic between nginx and the backend is intercepted,
requests.post(..., verify=False)accepts an untrusted certificate, letting the interceptor read or alter the identity attributes and session ID and affect the login response; users can be impersonated or receive attacker-controlled content.Enable certificate verification and configure the trusted CA for the backend.
Prompt for AI agents