Skip to content

Commit 17d8778

Browse files
authored
Allauth: define secrets in settings (#11156)
* Allauth: define secrets in settings Allauth used to merge the settings from the file and the database, this is not the case anymore. * Update tests
1 parent 112d9cd commit 17d8778

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

readthedocs/oauth/services/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ def create_session(self):
105105
}
106106
)
107107

108+
social_app = self.account.get_provider().app
108109
self.session = OAuth2Session(
109-
client_id=token.app.client_id,
110+
client_id=social_app.client_id,
110111
token=token_config,
111112
auto_refresh_kwargs={
112-
"client_id": token.app.client_id,
113-
"client_secret": token.app.secret,
113+
"client_id": social_app.client_id,
114+
"client_secret": social_app.secret,
114115
},
115116
auto_refresh_url=self.get_adapter().access_token_url,
116117
token_updater=self.token_updater(token),

readthedocs/rtd_tests/tests/test_oauth_sync.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import django_dynamic_fixture as fixture
22
import requests_mock
3-
from allauth.socialaccount.models import SocialAccount, SocialApp, SocialToken
3+
from allauth.socialaccount.models import SocialAccount, SocialToken
44
from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
55
from django.contrib.auth.models import User
66
from django.test import TestCase
@@ -61,18 +61,13 @@ class GitHubOAuthSyncTests(TestCase):
6161

6262
def setUp(self):
6363
self.user = fixture.get(User)
64-
self.socialapp = fixture.get(
65-
SocialApp,
66-
provider=GitHubOAuth2Adapter.provider_id,
67-
)
6864
self.socialaccount = fixture.get(
6965
SocialAccount,
7066
user=self.user,
7167
provider=GitHubOAuth2Adapter.provider_id,
7268
)
7369
self.token = fixture.get(
7470
SocialToken,
75-
app=self.socialapp,
7671
account=self.socialaccount,
7772
)
7873
self.service = GitHubService.for_user(self.user)[0]
@@ -293,7 +288,6 @@ def test_sync_repositories_only_creates_one_remote_repo_per_vcs_repo(
293288
)
294289
fixture.get(
295290
SocialToken,
296-
app=self.socialapp,
297291
account=user_2_socialaccount,
298292
)
299293

readthedocs/settings/base.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,13 @@ def DOCKER_LIMITS(self):
646646

647647
SOCIALACCOUNT_PROVIDERS = {
648648
'github': {
649+
"APPS": [
650+
{
651+
"client_id": "123",
652+
"secret": "456",
653+
"key": ""
654+
},
655+
],
649656
"VERIFIED_EMAIL": True,
650657
'SCOPE': [
651658
'user:email',
@@ -655,13 +662,29 @@ def DOCKER_LIMITS(self):
655662
],
656663
},
657664
'gitlab': {
665+
"APPS": [
666+
{
667+
"client_id": "123",
668+
"secret": "456",
669+
"key": ""
670+
},
671+
],
658672
"VERIFIED_EMAIL": True,
659673
'SCOPE': [
660674
'api',
661675
'read_user',
662676
],
663677
},
664-
# Bitbucket scope/permissions are determined by the Oauth consumer setup on bitbucket.org
678+
"bitbucket_oauth2": {
679+
"APPS": [
680+
{
681+
"client_id": "123",
682+
"secret": "456",
683+
"key": ""
684+
},
685+
],
686+
# Bitbucket scope/permissions are determined by the Oauth consumer setup on bitbucket.org.
687+
},
665688
}
666689
ACCOUNT_FORMS = {
667690
'signup': 'readthedocs.forms.SignupFormWithNewsletter',

0 commit comments

Comments
 (0)