Skip to content

Commit 423494d

Browse files
authored
Add the revoke_other_sessions attribute in login_options (#459)
1 parent dc10a8d commit 423494d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
"mypy-type-checker.importStrategy": "fromEnvironment",
88
"isort.importStrategy": "fromEnvironment",
99
"black-formatter.importStrategy": "fromEnvironment",
10+
"workbench.colorCustomizations": {
11+
"activityBar.background": "#121D85",
12+
"titleBar.activeBackground": "#1A28BA",
13+
"titleBar.activeForeground": "#F9FAFE"
14+
},
1015
}

descope/common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
self,
112112
stepup: bool = False,
113113
mfa: bool = False,
114+
revoke_other_sessions: Optional[None] = None,
114115
custom_claims: Optional[dict] = None,
115116
template_options: Optional[
116117
dict
@@ -119,6 +120,8 @@ def __init__(
119120
self.stepup = stepup
120121
self.customClaims = custom_claims
121122
self.mfa = mfa
123+
if revoke_other_sessions is not None:
124+
self.revokeOtherSessions = revoke_other_sessions
122125
if template_options is not None:
123126
self.templateOptions = template_options
124127

@@ -149,11 +152,13 @@ def validate_refresh_token_provided(
149152
class SignUpOptions:
150153
def __init__(
151154
self,
155+
revoke_other_sessions: Optional[None] = None,
152156
custom_claims: Optional[dict] = None,
153157
template_options: Optional[
154158
dict
155159
] = None, # for providing messaging template options (templates that are being sent via email / text message)
156160
):
161+
self.revoke_other_sessions = revoke_other_sessions
157162
self.customClaims = custom_claims
158163
self.templateOptions = template_options
159164

@@ -165,4 +170,6 @@ def signup_options_to_dict(signup_options: Optional[SignUpOptions] = None) -> di
165170
res["customClaims"] = signup_options.customClaims
166171
if signup_options.templateOptions is not None:
167172
res["templateOptions"] = signup_options.templateOptions
173+
if signup_options.revoke_other_sessions is not None:
174+
res["revokeOtherSessions"] = signup_options.revoke_other_sessions
168175
return res

tests/test_enchantedlink.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ def test_sign_in(self):
162162
enchantedlink.sign_in(
163163
164164
"http://test.me",
165-
LoginOptions(stepup=True, template_options={"blue": "bla"}),
165+
LoginOptions(
166+
stepup=True,
167+
template_options={"blue": "bla"},
168+
revoke_other_sessions=True,
169+
),
166170
refresh_token=refresh_token,
167171
)
168172
mock_post.assert_called_with(
@@ -179,6 +183,7 @@ def test_sign_in(self):
179183
"stepup": True,
180184
"customClaims": None,
181185
"templateOptions": {"blue": "bla"},
186+
"revokeOtherSessions": True,
182187
"mfa": False,
183188
},
184189
},
@@ -298,7 +303,9 @@ def test_sign_up(self):
298303
299304
"http://test.me",
300305
None,
301-
SignUpOptions(template_options={"bla": "blue"}),
306+
SignUpOptions(
307+
template_options={"bla": "blue"}, revoke_other_sessions=True
308+
),
302309
)
303310
mock_post.assert_called_with(
304311
f"{common.DEFAULT_BASE_URL}{EndpointsV1.sign_up_auth_enchantedlink_path}/email",
@@ -312,7 +319,10 @@ def test_sign_up(self):
312319
"URI": "http://test.me",
313320
"user": {"email": "[email protected]"},
314321
"email": "[email protected]",
315-
"loginOptions": {"templateOptions": {"bla": "blue"}},
322+
"loginOptions": {
323+
"templateOptions": {"bla": "blue"},
324+
"revokeOtherSessions": True,
325+
},
316326
},
317327
allow_redirects=False,
318328
verify=True,

0 commit comments

Comments
 (0)