-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2079 from botisan-ai/okta-login
Added Okta Login for newer versions of Doccano
- Loading branch information
Showing
21 changed files
with
146 additions
and
8 deletions.
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
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
Empty file.
Empty file.
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SocialConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "social" |
Empty file.
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,9 @@ | ||
from allauth.socialaccount.providers.oauth2.client import OAuth2Client | ||
from allauth.socialaccount.providers.okta.views import OktaOAuth2Adapter | ||
from dj_rest_auth.registration.views import SocialLoginView | ||
|
||
|
||
class OktaLogin(SocialLoginView): | ||
adapter_class = OktaOAuth2Adapter | ||
callback_url = "/projects" | ||
client_class = OAuth2Client |
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,7 @@ | ||
from django.urls import path | ||
|
||
from .okta import OktaLogin | ||
|
||
urlpatterns = [ | ||
path("complete/okta-oauth2/", OktaLogin.as_view(), name="okta_login"), | ||
] |
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,7 @@ | ||
from django.urls import path | ||
|
||
from .views import Social | ||
|
||
urlpatterns = [ | ||
path("links/", Social.as_view()), | ||
] |
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,26 @@ | ||
from django.conf import settings | ||
from rest_framework.response import Response | ||
from rest_framework.views import APIView | ||
|
||
|
||
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 {}, | ||
} | ||
) |
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,46 @@ | ||
<template> | ||
<div> | ||
<v-btn | ||
v-for="item in social" | ||
:key="item.provider" | ||
block | ||
elevation="2" | ||
color="secondary" | ||
:href="item.href" | ||
class="mt-5" | ||
> | ||
{{ $t('user.socialLogin', { provider: item.provider }) }} | ||
</v-btn> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
props: { | ||
fetchSocialLink: { | ||
type: Function, | ||
default: () => Promise | ||
} | ||
}, | ||
data() { | ||
return { | ||
social: {} | ||
} | ||
}, | ||
async mounted() { | ||
const response = await this.fetchSocialLink() | ||
this.social = Object.entries(response) | ||
.map(([key, value]: any) => ({ | ||
provider: key, | ||
value | ||
})) | ||
.filter((item) => !!item.value?.authorize_url) | ||
.map((item: any) => ({ | ||
...item, | ||
href: `${item.value.authorize_url}&redirect_uri=${location.origin}${item.value.redirect_path}` | ||
})) | ||
} | ||
}) | ||
</script> |
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
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
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