Django social account sso (#5059)
Issue: https://github.com/opencv/cvat/issues/1217 Currently there are a few proposals for SSO authentication to bypass the current user/password login on the UI. By using Django social accounts it is also possible to use SSO on the API, retrieving the security token by passing the code from the OAuth2 workflow. This is an example using Amazon Cognito, but any other social account could also be added. ### Motivation and context Currently CVAT has no functionality to log in with SSO. Other current proposals bypass the current Django framework to add SSO in the UI only, but still use username and password for the API. Using Django social accounts integrates SSO with the API as well, allowing it to be used as an alternative to the username and password, but can also be used together with other SSO frameworks that are UI only. ### How has this been tested? Unit tests for SSO manager in cvat-core and integration test with cvat-sdk for /auth/cognito endpoint. ### Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. If an item isn't applicable by a reason then ~~explicitly strikethrough~~ the whole line. If you don't do that github will show an incorrect process for the pull request. If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I submit my changes into the `develop` branch - [ ] I have added a description of my changes into [CHANGELOG](https://github.com/cvat-ai/cvat/blob/develop/CHANGELOG.md) file - [x] I have updated the [documentation]( https://github.com/cvat-ai/cvat/blob/develop/README.md#documentation) accordingly - [x] I have added tests to cover my changes - [x] I have linked related issues ([read github docs]( https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)) - [ ] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning), [cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning)) ### License - [x] I submit _my code changes_ under the same [MIT License]( https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. Co-authored-by: Melanie Day <mday@EYEDIAGNOSIS.local> Co-authored-by: Maria Khrustaleva <maria@cvat.ai> Co-authored-by: Nikita Manovich <nikita@cvat.ai>main
parent
9b55a7f7d4
commit
0f0913c138
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="32" height="32" viewBox="-21.5 0 299 299" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||||
|
<g>
|
||||||
|
<path d="M208.752,58.061 L234.523,51.425 L234.715,51.708 L235.366,207.315 L234.523,208.161 L229.213,208.388 L209.054,205.25 L208.752,204.456 L208.752,58.061" fill="#7A3E65">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M59.705,218.971 L59.8,218.978 L127.827,238.745 L128,238.878 L128.296,239.114 L128.2,298.346 L128,298.598 L59.705,265.42 L59.705,218.971" fill="#7A3E65">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M208.752,204.456 L128.112,223.768 L87.624,213.995 L59.705,218.971 L128,238.878 L233.405,210.341 L234.523,208.161 L208.752,204.456" fill="#CFB2C1">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M196.295,79.626 L195.638,78.877 L128.734,59.437 L128,59.72 L127.328,59.377 L22.052,89.734 L21.477,90.437 L22.322,90.9 L46.397,94.43 L47.248,94.141 L127.888,74.83 L168.376,84.603 L196.295,79.626" fill="#512843">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M47.248,240.537 L21.477,246.758 L21.432,246.609 L20.417,91.583 L21.477,90.437 L47.248,94.141 L47.248,240.537" fill="#C17B9E">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M82.04,180.403 L128,185.794 L128.345,185.279 L128.532,113.392 L128,112.803 L82.04,118.195 L82.04,180.403" fill="#7A3E65">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M173.96,180.403 L128,185.794 L128,112.803 L173.96,118.195 L173.96,180.403" fill="#C17B9E">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M196.295,79.626 L128,59.72 L128,0 L196.295,33.177 L196.295,79.626" fill="#C17B9E">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M128,0 L0,61.793 L0,236.804 L21.477,246.758 L21.477,90.437 L128,59.72 L128,0" fill="#7A3E65">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
<path d="M234.523,51.425 L234.523,208.161 L128,238.878 L128,298.598 L256,236.804 L256,61.793 L234.523,51.425" fill="#C17B9E">
|
||||||
|
|
||||||
|
</path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (C) 2023 CVAT.ai Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
from allauth.socialaccount.providers.amazon_cognito.views import AmazonCognitoOAuth2Adapter
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class TestAmazonCognitoOAuth2Adapter(AmazonCognitoOAuth2Adapter):
|
||||||
|
@property
|
||||||
|
def profile_url(self):
|
||||||
|
return super().profile_url.lower()
|
||||||
|
|
||||||
|
def get_callback_url(self, request, app):
|
||||||
|
return settings.AMAZON_COGNITO_REDIRECT_URI
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"interactiveLogin": true,
|
||||||
|
"httpServer": "NettyWrapper",
|
||||||
|
"tokenCallbacks": [
|
||||||
|
{
|
||||||
|
"issuerId": "oauth2",
|
||||||
|
"tokenExpiry": 120,
|
||||||
|
"requestMappings": [
|
||||||
|
{
|
||||||
|
"requestParam": "client_id",
|
||||||
|
"match": "test-client",
|
||||||
|
"claims": {
|
||||||
|
"sub": "test-sub",
|
||||||
|
"aud": [
|
||||||
|
"test-aud"
|
||||||
|
],
|
||||||
|
"email": "admin@localhost.company",
|
||||||
|
"email_verified": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
services:
|
||||||
|
mock_oauth2:
|
||||||
|
image: ghcr.io/navikt/mock-oauth2-server:0.5.3
|
||||||
|
environment:
|
||||||
|
JSON_CONFIG_PATH: "/devel/config.json"
|
||||||
|
SERVER_PORT: 9999
|
||||||
|
ports:
|
||||||
|
- 9999:9999
|
||||||
|
volumes:
|
||||||
|
- ./tests/python/mock_oauth2:/devel
|
||||||
|
networks:
|
||||||
|
- cvat
|
||||||
|
|
||||||
|
cvat_server:
|
||||||
|
environment:
|
||||||
|
USE_ALLAUTH_SOCIAL_ACCOUNTS: "True"
|
||||||
|
SOCIAL_AUTH_AMAZON_COGNITO_DOMAIN: "http://mock_oauth2:9999"
|
||||||
|
SOCIAL_AUTH_AMAZON_COGNITO_CLIENT_ID: "test-client"
|
||||||
|
DJANGO_SETTINGS_MODULE: mock_oauth2.settings
|
||||||
|
volumes:
|
||||||
|
- ./tests/python/mock_oauth2:/home/django/mock_oauth2:ro
|
||||||
|
depends_on:
|
||||||
|
- mock_oauth2
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (C) 2023 CVAT.ai Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
from cvat.settings.production import *
|
||||||
|
|
||||||
|
ACCOUNT_EMAIL_REQUIRED = True
|
||||||
|
|
||||||
|
if USE_ALLAUTH_SOCIAL_ACCOUNTS:
|
||||||
|
SOCIALACCOUNT_AMAZON_COGNITO_ADAPTER = "mock_oauth2.adapters.TestAmazonCognitoOAuth2Adapter"
|
||||||
Loading…
Reference in New Issue