Skip to content

Commit

Permalink
add a default scope of "openid profile email"
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Jan 11, 2021
1 parent 6751e4f commit 84dd717
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ The sample above requests tokens with the audience required to call the [Managem

```kotlin
WebAuthProvider.login(account)
.withScope("openid profile email")
.withScope("openid profile email read:users")
.start(this, callback)
```

> Regardless of the scopes passed, the `openid` scope is always enforced.
> The default scope used is `openid profile email`. Regardless of the scopes passed here, the `openid` scope is always enforced.
#### Specify Connection scope

Expand Down Expand Up @@ -313,7 +313,7 @@ authentication
})
```

> The default scope used is `openid`
> The default scope used is `openid profile email`

#### Login using MFA with One Time Password code
Expand Down Expand Up @@ -352,7 +352,7 @@ authentication
})
```

> The default scope used is `openid`
> The default scope used is `openid profile email`
Step 2: Input the code

Expand Down Expand Up @@ -537,7 +537,7 @@ The credentials to save **must have** `expires_in` and at least an `access_token
```kotlin
authentication
.login("info@auth0.com", "a secret password", "my-database-connection")
.setScope("openid offline_access")
.setScope("openid email profile offline_access")
.start(object : Callback<Credentials, AuthenticationException> {
override fun onFailure(exception: AuthenticationException) {
// Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ internal class OAuthManager(
}
val existingScopes = parameters[KEY_SCOPE]!!.split(" ")
.map { it.toLowerCase(Locale.ROOT) }
if (!existingScopes.contains(DEFAULT_SCOPE)) {
val requiredScopes = (existingScopes + DEFAULT_SCOPE).joinToString(separator = " ")
if (!existingScopes.contains(REQUIRED_SCOPE)) {
val requiredScopes = (existingScopes + REQUIRED_SCOPE).joinToString(separator = " ")
parameters[KEY_SCOPE] = requiredScopes
}
}
Expand Down Expand Up @@ -279,7 +279,8 @@ internal class OAuthManager(
const val KEY_CONNECTION = "connection"
const val KEY_SCOPE = "scope"
const val RESPONSE_TYPE_CODE = "code"
private const val DEFAULT_SCOPE = "openid"
private const val DEFAULT_SCOPE = "openid profile email"
private const val REQUIRED_SCOPE = "openid"
private const val ERROR_VALUE_INVALID_CONFIGURATION = "a0.invalid_configuration"
private const val ERROR_VALUE_ACCESS_DENIED = "access_denied"
private const val ERROR_VALUE_UNAUTHORIZED = "unauthorized"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public object WebAuthProvider {
}

/**
* Give a scope for this request.
* Give a scope for this request. The default scope used is "openid profile email".
* Regardless of the scopes passed, the "openid" scope is always enforced.
*
* @param scope to request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public class WebAuthProviderTest {
val uri =
intentCaptor.firstValue.getParcelableExtra<Uri>(AuthenticationActivity.EXTRA_AUTHORIZE_URI)
MatcherAssert.assertThat(uri, `is`(notNullValue()))
MatcherAssert.assertThat(uri, UriMatchers.hasParamWithValue("scope", "openid"))
MatcherAssert.assertThat(uri, UriMatchers.hasParamWithValue("scope", "openid profile email"))
}

@Test
Expand Down

0 comments on commit 84dd717

Please sign in to comment.