-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
214 additions
and
24 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
15 changes: 14 additions & 1 deletion
15
android-sdk/android/src/main/kotlin/io/logto/sdk/android/type/LogtoConfig.kt
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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
package io.logto.sdk.android.type | ||
|
||
import io.logto.sdk.core.constant.PromptValue | ||
import io.logto.sdk.core.constant.ReservedResource | ||
import io.logto.sdk.core.constant.UserScope | ||
import io.logto.sdk.core.util.ScopeUtils | ||
|
||
class LogtoConfig( | ||
val endpoint: String, | ||
val appId: String, | ||
scopes: List<String>? = null, | ||
val resources: List<String>? = null, | ||
resources: List<String>? = null, | ||
val usingPersistStorage: Boolean = true, | ||
val prompt: String = PromptValue.CONSENT, | ||
) { | ||
/** | ||
* Normalize the Logto client configuration per the following rules: | ||
* | ||
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided. | ||
* - Add `ReservedResource.Organization` to resources if `UserScope.Organizations` is included in scopes. | ||
*/ | ||
val scopes = ScopeUtils.withDefaultScopes(scopes) | ||
val resources = if (this.scopes.contains(UserScope.ORGANIZATIONS)) { | ||
(resources.orEmpty() + ReservedResource.ORGANIZATION) | ||
} else { | ||
resources | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
kotlin-sdk/kotlin/src/main/kotlin/io/logto/sdk/core/constant/ReservedResource.kt
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,5 @@ | ||
package io.logto.sdk.core.constant | ||
|
||
object ReservedResource { | ||
const val ORGANIZATION = "urn:logto:resource:organizations" | ||
} |
Oops, something went wrong.