Browse Source

fix lint issue

pull/2079/head
Clovin 2 years ago
parent
commit
441a8b5230
7 changed files with 30 additions and 27 deletions
  1. 11
      backend/config/settings/base.py
  2. 4
      backend/config/urls.py
  3. 6
      backend/pyproject.toml
  4. 2
      backend/social/okta.py
  5. 2
      backend/social/urls.py
  6. 2
      backend/social/v1_urls.py
  7. 30
      backend/social/views.py

11
backend/config/settings/base.py

@ -283,12 +283,9 @@ CELERY_RESULT_SERIALIZER = "json"
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
SOCIALACCOUNT_PROVIDERS = {
'okta': {
'OKTA_BASE_URL': env("OAUTH_OKTA_OAUTH2_API_URL", ''),
'OAUTH_PKCE_ENABLED': True,
'APP': {
'client_id': env("OAUTH_OKTA_OAUTH2_KEY", ''),
'secret': env("OAUTH_OKTA_OAUTH2_SECRET", '')
}
"okta": {
"OKTA_BASE_URL": env("OAUTH_OKTA_OAUTH2_API_URL", ""),
"OAUTH_PKCE_ENABLED": True,
"APP": {"client_id": env("OAUTH_OKTA_OAUTH2_KEY", ""), "secret": env("OAUTH_OKTA_OAUTH2_SECRET", "")},
}
}

4
backend/config/urls.py

@ -52,8 +52,8 @@ if settings.DEBUG or os.environ.get("STANDALONE", False):
urlpatterns += [
path("admin/", admin.site.urls),
path("api-auth/", include("rest_framework.urls")),
path('social/', include("social.urls")),
path('v1/social/', include("social.v1_urls")),
path("social/", include("social.urls")),
path("v1/social/", include("social.v1_urls")),
path("v1/health/", include("health_check.urls")),
path("v1/", include("api.urls")),
path("v1/", include("roles.urls")),

6
backend/pyproject.toml

@ -125,7 +125,8 @@ known_first_party = [
"metrics",
"projects",
"roles",
"users"
"users",
"social"
]
known_local_folder = [
"api",
@ -139,7 +140,8 @@ known_local_folder = [
"metrics",
"projects",
"roles",
"users"
"users",
"social"
]
[tool.taskipy.tasks]

2
backend/social/okta.py

@ -5,5 +5,5 @@ from dj_rest_auth.registration.views import SocialLoginView
class OktaLogin(SocialLoginView):
adapter_class = OktaOAuth2Adapter
callback_url = '/projects'
callback_url = "/projects"
client_class = OAuth2Client

2
backend/social/urls.py

@ -3,5 +3,5 @@ from django.urls import path
from .okta import OktaLogin
urlpatterns = [
path('complete/okta-oauth2/', OktaLogin.as_view(), name='okta_login'),
path("complete/okta-oauth2/", OktaLogin.as_view(), name="okta_login"),
]

2
backend/social/v1_urls.py

@ -3,5 +3,5 @@ from django.urls import path
from .views import Social
urlpatterns = [
path('links/', Social.as_view()),
path("links/", Social.as_view()),
]

30
backend/social/views.py

@ -7,16 +7,20 @@ class Social(APIView):
permission_classes = ()
def get(self, request, *args, **kwargs):
return Response({
'okta': {
'type': 'oauth2',
'base_url': settings.SOCIALACCOUNT_PROVIDERS.get('okta').get('OKTA_BASE_URL'),
'client_id': settings.SOCIALACCOUNT_PROVIDERS.get('okta').get('APP').get('client_id'),
'redirect_path': '/social/complete/okta-oauth2',
'authorize_url':
'https://' + settings.SOCIALACCOUNT_PROVIDERS.get('okta').get('OKTA_BASE_URL')
+ '/oauth2/v1/authorize?response_type=code&client_id='
+ settings.SOCIALACCOUNT_PROVIDERS.get('okta').get('APP').get('client_id')
+ '&scope=openid&state=unknown&response_mode=form_post',
} if settings.SOCIALACCOUNT_PROVIDERS.get('okta').get('OKTA_BASE_URL') else {},
})
return Response(
{
"okta": {
"type": "oauth2",
"base_url": settings.SOCIALACCOUNT_PROVIDERS.get("okta").get("OKTA_BASE_URL"),
"client_id": settings.SOCIALACCOUNT_PROVIDERS.get("okta").get("APP").get("client_id"),
"redirect_path": "/social/complete/okta-oauth2",
"authorize_url": "https://"
+ settings.SOCIALACCOUNT_PROVIDERS.get("okta").get("OKTA_BASE_URL")
+ "/oauth2/v1/authorize?response_type=code&client_id="
+ settings.SOCIALACCOUNT_PROVIDERS.get("okta").get("APP").get("client_id")
+ "&scope=openid&state=unknown&response_mode=form_post",
}
if settings.SOCIALACCOUNT_PROVIDERS.get("okta").get("OKTA_BASE_URL")
else {},
}
)
Loading…
Cancel
Save