Skip to content

Commit

Permalink
SDKS-3617 Makes logger independent for each DaVinci Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
witrisna committed Nov 26, 2024
1 parent b69b361 commit a00c6e7
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ val Oidc =
* Initializes the module.
*/
init {

logger.i(
"Initializing the OIDC module: the httpClient, logger, " +
"and agent will be propagated from DaVinci. " +
"Any explicit settings for these in the OIDC module will be ignored."
)
// propagate the configuration from workflow to the module
config.httpClient = httpClient
config.logger = logger
Expand Down Expand Up @@ -78,7 +84,7 @@ val Oidc =
* Handles sign off of the module.
*/
signOff { request ->
request.url(config.openId.endSessionEndpoint)
request.url(config.openId.endSessionEndpoint)
OidcClient(config).endSession {
request.parameter("id_token_hint", it)
request.parameter("client_id", config.clientId)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package com.pingidentity.orchestrate

import androidx.annotation.VisibleForTesting
import com.pingidentity.logger.LoggerContext
import com.pingidentity.logger.Logger
import com.pingidentity.logger.None
import com.pingidentity.utils.PingDsl
import io.ktor.client.HttpClient
Expand Down Expand Up @@ -40,11 +40,10 @@ open class WorkflowConfig {
var timeout: Long = 15000

// Logger for the log, default is None
var logger = LoggerContext.get()
var logger = Logger.logger
set(value) {
field = value
// Propagate the logger to Modules
LoggerContext.put(value)
Logger.logger = value
}

// HTTP client for the engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.security.keystore.StrongBoxUnavailableException
import com.pingidentity.android.ContextProvider
import com.pingidentity.logger.LoggerContext
import com.pingidentity.logger.Logger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
Expand Down Expand Up @@ -60,7 +60,7 @@ class SecretKeyEncryptorConfig {
var throwWhenEncryptError = true
var symmetricKeySize = 256
var invalidatedByBiometricEnrollment = true
var logger = LoggerContext.get()
var logger = Logger.logger

/**
* Initializes the context if it's not already initialized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,50 @@ import kotlinx.coroutines.launch
//val Context.dataStore: androidx.datastore.core.DataStore<AccessToken?> by dataStore("test", DataStoreSerializer())
//val dataStore = DataStoreStorage(ContextProvider.context.dataStore)

val test = DaVinci {
logger = Logger.STANDARD

// Oidc as module
module(Oidc) {
clientId = "3172d977-8fdc-4e8b-b3c5-4f3a34cb7262"
discoveryEndpoint =
"https://auth.test-one-pingone.com/0c6851ed-0f12-4c9a-a174-9b1bf8b438ae/as/.well-known/openid-configuration"
scopes = mutableSetOf("openid", "email", "address")
redirectUri = "org.forgerock.demo://oauth2redirect"
//storage = dataStore
val test by lazy {
DaVinci {
logger = Logger.STANDARD

// Oidc as module
module(Oidc) {
clientId = "3172d977-8fdc-4e8b-b3c5-4f3a34cb7262"
discoveryEndpoint =
"https://auth.test-one-pingone.com/0c6851ed-0f12-4c9a-a174-9b1bf8b438ae/as/.well-known/openid-configuration"
scopes = mutableSetOf("openid", "email", "address")
redirectUri = "org.forgerock.demo://oauth2redirect"
//storage = dataStore
}
}
}

val prod = DaVinci {
logger = Logger.STANDARD

// Oidc as module
module(Oidc) {
clientId = "3d3f7650-2dea-4a42-8bf9-8bb6b96d30c7"
discoveryEndpoint = "https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration"
scopes = mutableSetOf("openid", "email", "address", "phone", "profile")
redirectUri = "org.forgerock.demo://oauth2redirect"
//storage = dataStore
val prod by lazy {
DaVinci {
logger = Logger.STANDARD

// Oidc as module
module(Oidc) {
clientId = "c12743f9-08e8-4420-a624-71bbb08e9fe1"
discoveryEndpoint =
"https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration"
scopes = mutableSetOf("openid", "email", "address", "phone", "profile")
redirectUri = "org.forgerock.demo://oauth2redirect"
}
}
}

val socialLoginTest = DaVinci {
logger = Logger.STANDARD

// Oidc as module
module(Oidc) {
clientId = "9c7767b5-3a9d-4e9c-9d65-9fc77ccfd284"
discoveryEndpoint =
"https://auth.pingone.com/c2a669c0-c396-4544-994d-9c6eb3fb1602/as/.well-known/openid-configuration"
scopes = mutableSetOf("openid", "email", "address")
redirectUri = "com.pingidentity.demo://oauth2redirect"
//storage = dataStore
val socialLoginTest by lazy {
DaVinci {
logger = Logger.STANDARD

// Oidc as module
module(Oidc) {
clientId = "9c7767b5-3a9d-4e9c-9d65-9fc77ccfd284"
discoveryEndpoint =
"https://auth.pingone.com/c2a669c0-c396-4544-994d-9c6eb3fb1602/as/.well-known/openid-configuration"
scopes = mutableSetOf("openid", "email", "address")
redirectUri = "com.pingidentity.demo://oauth2redirect"
//storage = dataStore
}
}
}

Expand Down

0 comments on commit a00c6e7

Please sign in to comment.