-
Notifications
You must be signed in to change notification settings - Fork 95
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
merge of Gsoc2023 nilupul manodya #2069
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e06b396
remove inputs from conditions (#1808)
nilupulmanodya 8471ba1
Setup sp and idp for the sso (#1809)
nilupulmanodya f2b1434
Split conf sp idp (#1811)
nilupulmanodya 106bee5
UI changes in Qt for SSO (#1813)
nilupulmanodya 245d64e
web browser implementation (#1814)
nilupulmanodya 4c556a3
Configure mscolab for sso (#1818)
nilupulmanodya 529e7f6
To do fixes #1818 (#1974)
nilupulmanodya 198cf88
improve code for multiple Idps
nilupulmanodya db82eb7
conf routes for multiple conf
nilupulmanodya 90a1c62
remove uncessary .yaml
nilupulmanodya df4ae37
update cmd metadata
nilupulmanodya 8dd2c9e
update conf
nilupulmanodya 05f3c2c
update saml handler for multiple idps
nilupulmanodya aa47a09
pinning of xmlschema
nilupulmanodya 1912fd4
pin werkzeug
nilupulmanodya 77f21d3
disable pytests for todo refactor
nilupulmanodya cf2a3b9
disbale whole file gsoc_testing
nilupulmanodya c7ab2ae
fix conf
nilupulmanodya 34e7e33
resolve comments
nilupulmanodya b02854a
resolve comments
nilupulmanodya f94da54
Merge pull request #2043 from nilupulmanodya/implement-mscolab-for-mu…
ReimarBauer 458a978
Merge branch 'develop' of https://github.com/nilupulmanodya/MSS into …
nilupulmanodya 2d59aa5
manual conflict resolve ui_mscolab_connect_dialog.ui file
nilupulmanodya 18a9e7c
resolve flake8
nilupulmanodya ef326c2
Merge pull request #2061 from nilupulmanodya/merge_current_develop
ReimarBauer 3d328f9
set SSL certificate verification enablement (#2062)
nilupulmanodya eefc67c
Remove testing SP (#2066)
nilupulmanodya 8d88932
Create documentation for SSO integration through SAML (#2064)
nilupulmanodya 30a04ea
change cookies dir of web browser (#2063)
nilupulmanodya a2e10e1
improve accessibility saml2 urls (#2068)
nilupulmanodya 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 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 |
---|---|---|
|
@@ -24,4 +24,5 @@ build/ | |
mss.egg-info/ | ||
tutorials/recordings | ||
tutorials/cursor_image.png | ||
|
||
__pycache__/ | ||
instance/ | ||
This file contains 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 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 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 |
---|---|---|
|
@@ -10,5 +10,6 @@ Components | |
mscolab | ||
gentutorials | ||
mssautoplot | ||
|
||
|
||
conf_auth_client_sp_idp | ||
conf_sso_test_msscolab | ||
sso_via_saml_mscolab |
This file contains 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,117 @@ | ||
Configuration MSS Colab Server with Testing IdP for SSO | ||
======================================================= | ||
Testing IDP (`mslib/msidp`) is specifically designed for testing the Single Sign-On (SSO) process with the mscolab server using PySAML2. | ||
|
||
Here is documentation that explains the configuration of the MSS Colab Server with the testing IdP. | ||
|
||
Getting started | ||
--------------- | ||
|
||
To set up a local identity provider with the mscolab server, you'll first need to generate the required keys and certificates for both the Identity Provider and the mscolab server. Follow these steps to configure the system: | ||
|
||
1. Initial Steps | ||
2. Generate Keys and Certificates | ||
3. Enable USE_SAML2 | ||
4. Generate Metadata Files | ||
5. Start the Identity Provider | ||
6. Start the mscolab Server | ||
7. Test the Single Sign-On (SSO) Process | ||
|
||
|
||
1. Initial Steps | ||
---------------- | ||
Before getting started, you should correctly activate the environments, set the correct Python path as explained in the mss instructions : https://github.com/Open-MSS/MSS/tree/develop#readme | ||
|
||
|
||
|
||
2. Generate Keys, Certificates, and backend_saml files | ||
------------------------------------------------------ | ||
|
||
This involves generating both `.key` files and `.crt` files for both the Identity provider and mscolab server and `backend_saml.yaml` file. | ||
|
||
Before running the command make sure to set `USE_SAML2 = False` in your `mscolab_settings.py` file, You can accomplish this by following these steps: | ||
|
||
- Add to the `PYTHONPATH` where your `mscolab_settings.py`. | ||
- Add `USE_SAML2 = False` in your `mscolab_settings.py` file. | ||
|
||
.. note:: | ||
If you set `USE_SAML2 = True` without keys and certificates, this will not execute. So, make sure to set `USE_SAML2 = False` before executing the command. | ||
|
||
If everything is correctly set, you can generate keys and certificates simply by running | ||
|
||
.. code:: text | ||
|
||
$ mscolab sso_conf --init_sso_crts | ||
|
||
.. note:: | ||
This process generating keys and certificates for both Identity provider and mscolab server by default, If you need configure with different keys and certificates for the Identity provider, You should manually update the path of `SERVER_CERT` with the path of the generated .crt file for Identity provider, and `SERVER_KEY` with the path of the generated .key file for the Identity provider in the file `MSS/mslib/idp/idp_conf.py`. | ||
|
||
|
||
3. Enable USE_SAML2 | ||
------------------- | ||
|
||
To enable SAML2-based login (identity provider-based login), | ||
|
||
- To start the process update `USE_SAML2 = True` in your `mscolab_settings.py` file. | ||
|
||
.. note:: | ||
After enabling the `USE_SAML2` option, the subsequent step involves adding the `CONFIGURED_IDPS` dictionary for the MSS Colab Server. This dictionary must contain keys for each active Identity Provider, denoted by their `idp_identity_name`, along with their respective `idp_name`. Once this dictionary is configured, it should be utilized to update several aspects of the mscolab server, including the SAML2Client configuration in the .yml file. This ensures seamless integration with the enabled IDPs. By default, configuration has been set up for the localhost IDP, and any additional configurations required should be performed by the developer. | ||
|
||
4. Generate metadata files | ||
-------------------------- | ||
|
||
This involves generating necessary metadata files for both the identity provider and the service provider. You can generate them by simply running the below command. | ||
|
||
.. note:: | ||
Before executing this, you should set `USE_SAML2=True` as described in the third step(Enable USE_SAML2). | ||
|
||
.. code:: text | ||
|
||
$ mscolab sso_conf --init_sso_metadata | ||
|
||
|
||
5. Start Identity provider | ||
-------------------------- | ||
|
||
Once you set certificates and metada files you can start mscolab server and local identity provider. To start local identity provider, simply execute: | ||
|
||
.. code:: text | ||
|
||
$ msidp | ||
|
||
|
||
6. Start the mscolab Server | ||
--------------------------- | ||
|
||
Before Starting the mscolab server, make sure to do necessary database migrations. | ||
|
||
When this is the first time you setup a mscolab server, you have to initialize the database by: | ||
|
||
.. code:: text | ||
|
||
$ mscolab db --init | ||
|
||
.. note:: | ||
An existing database maybe needs a migration, have a look for this on our documentation. | ||
|
||
https://mss.readthedocs.io/en/stable/mscolab.html#data-base-migration | ||
|
||
When migrations finished, you can start mscolab server using the following command: | ||
|
||
.. code:: text | ||
|
||
$ mscolab start | ||
|
||
|
||
7. Testing Single Sign-On (SSO) process | ||
--------------------------------------- | ||
|
||
* Once you have successfully launched the server and identity provider, you can begin testing the Single Sign-On (SSO) process. | ||
* Start MSS PyQt application: | ||
|
||
.. code:: text | ||
|
||
$ msui | ||
|
||
* Login with identity provider through Qt Client application. | ||
* To log in to the mscolab server through the identity provider, you can use the credentials specified in the ``PASSWD`` section of the ``MSS/mslib/msidp/idp.py`` file. Look for the relevant section in the file to find the necessary login credentials. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
116 changes: 116 additions & 0 deletions
116
docs/samples/config/mscolab/mss_saml2_backend.yaml.samlple
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. I think the ending should be ".sample"? |
This file contains 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,116 @@ | ||
name: Saml2 | ||
config: | ||
entityid_endpoint: true | ||
mirror_force_authn: no | ||
memorize_idp: no | ||
use_memorized_idp_when_force_authn: no | ||
send_requester_id: no | ||
enable_metadata_reload: no | ||
|
||
# SP Configuration for localhost_test_idp | ||
localhost_test_idp: | ||
name: "MSS Colab Server - Testing IDP(localhost)" | ||
description: "MSS Collaboration Server with Testing IDP(localhost)" | ||
key_file: path/to/key_sp.key # Will be set from the mscolab server | ||
cert_file: path/to/crt_sp.crt # Will be set from the mscolab server | ||
verify_ssl_cert: true # Specifies if the SSL certificates should be verified. | ||
organization: {display_name: Open-MSS, name: Mission Support System, url: 'https://open-mss.github.io/about/'} | ||
contact_person: | ||
- {contact_type: technical, email_address: [email protected], given_name: Technical} | ||
- {contact_type: support, email_address: [email protected], given_name: Support} | ||
|
||
metadata: | ||
local: [path/to/idp.xml] # Will be set from the mscolab server | ||
|
||
entityid: http://localhost:5000/proxy_saml2_backend.xml | ||
accepted_time_diff: 60 | ||
service: | ||
sp: | ||
ui_info: | ||
display_name: | ||
- lang: en | ||
text: "Open MSS" | ||
description: | ||
- lang: en | ||
text: "Mission Support System" | ||
information_url: | ||
- lang: en | ||
text: "https://open-mss.github.io/about/" | ||
privacy_statement_url: | ||
- lang: en | ||
text: "https://open-mss.github.io/about/" | ||
keywords: | ||
- lang: en | ||
text: ["MSS"] | ||
- lang: en | ||
text: ["OpenMSS"] | ||
logo: | ||
text: "https://open-mss.github.io/assets/logo.png" | ||
width: "100" | ||
height: "100" | ||
authn_requests_signed: true | ||
want_response_signed: true | ||
want_assertion_signed: true | ||
allow_unknown_attributes: true | ||
allow_unsolicited: true | ||
endpoints: | ||
assertion_consumer_service: | ||
- [http://localhost:8083/localhost_test_idp/acs/post, 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'] | ||
discovery_response: | ||
- [<base_url>/<name>/disco, 'urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol'] | ||
name_id_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' | ||
name_id_format_allow_create: true | ||
|
||
|
||
# # SP Configuration for IDP 2 | ||
# sp_config_idp_2: | ||
# name: "MSS Colab Server - Testing IDP(localhost)" | ||
# description: "MSS Collaboration Server with Testing IDP(localhost)" | ||
# key_file: mslib/mscolab/app/key_sp.key | ||
# cert_file: mslib/mscolab/app/crt_sp.crt | ||
# organization: {display_name: Open-MSS, name: Mission Support System, url: 'https://open-mss.github.io/about/'} | ||
# contact_person: | ||
# - {contact_type: technical, email_address: [email protected], given_name: Technical} | ||
# - {contact_type: support, email_address: [email protected], given_name: Support} | ||
|
||
# metadata: | ||
# local: [mslib/mscolab/app/idp.xml] | ||
|
||
# entityid: http://localhost:5000/proxy_saml2_backend.xml | ||
# accepted_time_diff: 60 | ||
# service: | ||
# sp: | ||
# ui_info: | ||
# display_name: | ||
# - lang: en | ||
# text: "Open MSS" | ||
# description: | ||
# - lang: en | ||
# text: "Mission Support System" | ||
# information_url: | ||
# - lang: en | ||
# text: "https://open-mss.github.io/about/" | ||
# privacy_statement_url: | ||
# - lang: en | ||
# text: "https://open-mss.github.io/about/" | ||
# keywords: | ||
# - lang: en | ||
# text: ["MSS"] | ||
# - lang: en | ||
# text: ["OpenMSS"] | ||
# logo: | ||
# text: "https://open-mss.github.io/assets/logo.png" | ||
# width: "100" | ||
# height: "100" | ||
# authn_requests_signed: true | ||
# want_response_signed: true | ||
# want_assertion_signed: true | ||
# allow_unknown_attributes: true | ||
# allow_unsolicited: true | ||
# endpoints: | ||
# assertion_consumer_service: | ||
# - [http://localhost:8083/idp2/acs/post, 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'] | ||
# discovery_response: | ||
# - [<base_url>/<name>/disco, 'urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol'] | ||
# name_id_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' | ||
# name_id_format_allow_create: true | ||
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. This file is missing a newline after the last line. |
This file contains 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,68 @@ | ||
import os | ||
import sys | ||
import warnings | ||
import yaml | ||
from saml2 import SAMLError | ||
from saml2.client import Saml2Client | ||
from saml2.config import SPConfig | ||
from urllib.parse import urlparse | ||
|
||
|
||
class setup_saml2_backend: | ||
from mslib.mscolab.conf import mscolab_settings | ||
|
||
CONFIGURED_IDPS = [ | ||
# configure your idps here | ||
{ | ||
'idp_identity_name': 'localhost_test_idp', # make sure to use underscore for the blanks | ||
'idp_data': { | ||
'idp_name': 'Testing Identity Provider', # this name is used on the Login page to connect to the Provider. | ||
} | ||
}, | ||
|
||
] | ||
|
||
if os.path.exists(f"{mscolab_settings.MSCOLAB_SSO_DIR}/mss_saml2_backend.yaml"): | ||
with open(f"{mscolab_settings.MSCOLAB_SSO_DIR}/mss_saml2_backend.yaml", encoding="utf-8") as fobj: | ||
yaml_data = yaml.safe_load(fobj) | ||
# go through configured IDPs and set conf file paths for particular files | ||
for configured_idp in CONFIGURED_IDPS: | ||
# set CRTs and metadata paths for the localhost_test_idp | ||
if 'localhost_test_idp' == configured_idp['idp_identity_name']: | ||
yaml_data["config"]["localhost_test_idp"]["key_file"] = \ | ||
f'{mscolab_settings.MSCOLAB_SSO_DIR}/key_mscolab.key' # set path to your mscolab key file | ||
yaml_data["config"]["localhost_test_idp"]["cert_file"] = \ | ||
f'{mscolab_settings.MSCOLAB_SSO_DIR}/crt_mscolab.crt' # set path to your mscolab certiticate file | ||
yaml_data["config"]["localhost_test_idp"]["metadata"]["local"][0] = \ | ||
f'{mscolab_settings.MSCOLAB_SSO_DIR}/idp.xml' # set path to your idp metadata xml file | ||
|
||
# configuration localhost_test_idp Saml2Client | ||
try: | ||
if not os.path.exists(yaml_data["config"]["localhost_test_idp"]["metadata"]["local"][0]): | ||
yaml_data["config"]["localhost_test_idp"]["metadata"]["local"] = [] | ||
warnings.warn("idp.xml file does not exists !\ | ||
Ignore this warning when you initializeing metadata.") | ||
|
||
localhost_test_idp = SPConfig().load(yaml_data["config"]["localhost_test_idp"]) | ||
sp_localhost_test_idp = Saml2Client(localhost_test_idp) | ||
|
||
configured_idp['idp_data']['saml2client'] = sp_localhost_test_idp | ||
for url_pair in (yaml_data["config"]["localhost_test_idp"] | ||
["service"]["sp"]["endpoints"]["assertion_consumer_service"]): | ||
saml_url, binding = url_pair | ||
path = urlparse(saml_url).path | ||
configured_idp['idp_data']['assertion_consumer_endpoints'] = \ | ||
configured_idp['idp_data'].get('assertion_consumer_endpoints', []) + [path] | ||
|
||
except SAMLError: | ||
warnings.warn("Invalid Saml2Client Config with localhost_test_idp ! Please configure with\ | ||
valid CRTs metadata and try again.") | ||
sys.exit() | ||
|
||
# if multiple IdPs exists, development should need to implement accordingly below | ||
""" | ||
if 'idp_2'== configured_idp['idp_identity_name']: | ||
# rest of code | ||
# set CRTs and metadata paths for the idp_2 | ||
# configuration idp_2 Saml2Client | ||
""" |
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.
Where was that line coming from again? I cannot remember what this path was used for. Is it still required?