Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up native auth msal logging #2071

Merged
merged 21 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7f12ec7
MsalClientException instead of LogSession or Logger
Yuki-YuXin Mar 27, 2024
9cfb22e
Remove one Logger.verbose
Yuki-YuXin Mar 27, 2024
6c4d8ae
Remove LogSession.logMethodCall in the callback variant
Yuki-YuXin Mar 27, 2024
a12f4d5
Remove LogSession.logMethodCall in the callback variant of states
Yuki-YuXin Mar 27, 2024
aa97764
Revert changes on NativeAuthPublicClientApplicationConfiguration.kt. …
Yuki-YuXin Mar 27, 2024
23e7ae0
Rules applied:
Yuki-YuXin Apr 4, 2024
c4e6b5d
Merge branch 'dev' into yuki/log-cleaning
Yuki-YuXin Apr 5, 2024
76a458f
Revert changes on NativeAuthPublicClientApplicationConfigurationFacto…
Yuki-YuXin Apr 10, 2024
9dfb652
Revert Log.Session into interfaces and use arguments to distinguish c…
Yuki-YuXin Apr 10, 2024
e20c55b
Put sign in has password SignInResult.CodeRequired Logger warn back
Yuki-YuXin Apr 11, 2024
d7d9032
Sample for logging attributes checking test
Yuki-YuXin Apr 26, 2024
c448b88
Fixing
Yuki-YuXin Apr 26, 2024
740f5b7
Revert "Fixing"
Yuki-YuXin Apr 29, 2024
8e6d9a0
Revert "Sample for logging attributes checking test"
Yuki-YuXin Apr 29, 2024
32231ee
Merge branch 'dev' into yuki/log-cleaning
Yuki-YuXin Apr 29, 2024
ad0e0ba
Use new log methods
Yuki-YuXin Apr 29, 2024
c70e29b
Merge branch 'dev' into yuki/log-cleaning
Yuki-YuXin May 10, 2024
e6eb835
Merge branch 'dev' into yuki/log-cleaning
Yuki-YuXin May 16, 2024
6688506
Merge branch 'dev' into yuki/log-cleaning
Yuki-YuXin May 24, 2024
9eea339
Address comments
Yuki-YuXin May 31, 2024
c484724
Merge branch 'dev' into yuki/log-cleaning
Yuki-YuXin May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.getCurrentAccountInternal"
methodName = "${TAG}.getCurrentAccountInternal(config: NativeAuthPublicClientApplicationConfiguration)"
)

val params = CommandParametersAdapter.createCommandParameters(
Expand Down Expand Up @@ -164,7 +164,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.getAccountFromICacheRecordsList"
methodName = "${TAG}.getAccountFromICacheRecordsList(cacheRecords: List<ICacheRecord?>?)"
)
if (cacheRecords.isNullOrEmpty()) {
return null
Expand Down Expand Up @@ -230,6 +230,11 @@ class NativeAuthPublicClientApplication(
* @return [com.microsoft.identity.nativeauth.statemachine.states.AccountState] if there is a signed in account, null otherwise.
*/
override fun getCurrentAccount(callback: GetCurrentAccountCallback) {
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.getCurrentAccount(callback: GetCurrentAccountCallback)"
)
pcaScope.launch {
try {
val result = getCurrentAccount()
Expand All @@ -246,6 +251,11 @@ class NativeAuthPublicClientApplication(
* @return [com.microsoft.identity.nativeauth.statemachine.states.AccountState] if there is a signed in account, null otherwise.
*/
override suspend fun getCurrentAccount(): GetAccountResult {
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.getCurrentAccount"
)
return withContext(Dispatchers.IO) {
try {
val account = getCurrentAccountInternal(nativeAuthConfig)
Expand Down Expand Up @@ -291,7 +301,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
SammyO marked this conversation as resolved.
Show resolved Hide resolved
tag = TAG,
correlationId = null,
methodName = "${TAG}.signIn"
methodName = "${TAG}.signIn(username: String, password: CharArray?, scopes: List<String>?, callback: SignInCallback)"
)
pcaScope.launch {
try {
Expand Down Expand Up @@ -321,7 +331,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.signIn"
methodName = "${TAG}.signIn(username: String, password: CharArray?, scopes: List<String>?)"
)
return withContext(Dispatchers.IO) {
try {
Expand Down Expand Up @@ -373,6 +383,7 @@ class NativeAuthPublicClientApplication(
} else {
Logger.warnWithObject(
TAG,
result.correlationId,
"Sign in received unexpected result: ",
result
)
Expand Down Expand Up @@ -525,7 +536,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.signUp"
methodName = "${TAG}.signUp(username: String, password: CharArray?, attributes: UserAttributes?, callback: SignUpCallback)"
)
pcaScope.launch {
try {
Expand Down Expand Up @@ -554,7 +565,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.signUp"
methodName = "${TAG}.signUp(username: String, password: CharArray?, attributes: UserAttributes?)"
)
var hasPassword = password?.isNotEmpty() == true

Expand Down Expand Up @@ -637,6 +648,7 @@ class NativeAuthPublicClientApplication(
if (hasPassword) {
Logger.warnWithObject(
TAG,
result.correlationId,
"Sign up using password received unexpected result: ",
result
)
Expand Down Expand Up @@ -677,6 +689,7 @@ class NativeAuthPublicClientApplication(
} else {
Logger.warnWithObject(
TAG,
result.correlationId,
"Sign up received unexpected result: ",
result
)
Expand Down Expand Up @@ -759,7 +772,7 @@ class NativeAuthPublicClientApplication(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "${TAG}.resetPassword"
methodName = "${TAG}.resetPassword(username: String, callback: ResetPasswordCallback)"
)
pcaScope.launch {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ import com.microsoft.identity.client.PublicClientApplicationConfiguration
import com.microsoft.identity.client.configuration.AccountMode
import com.microsoft.identity.client.exception.MsalClientException
import com.microsoft.identity.common.java.authorities.CIAMAuthority
import com.microsoft.identity.common.java.nativeauth.authorities.NativeAuthCIAMAuthority
import com.microsoft.identity.common.java.logging.LogSession
import com.microsoft.identity.common.java.logging.Logger
import com.microsoft.identity.common.java.nativeauth.authorities.NativeAuthCIAMAuthority
import com.microsoft.identity.common.java.nativeauth.providers.NativeAuthConstants
import lombok.Getter
import lombok.experimental.Accessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class AccountState private constructor(
LogSession.logMethodCall(
SammyO marked this conversation as resolved.
Show resolved Hide resolved
tag = TAG,
correlationId = null,
methodName = "$TAG.signOut"
methodName = "${TAG}.signOut(callback: SignOutCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand All @@ -112,7 +112,7 @@ class AccountState private constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "$TAG.signOut.withContext"
methodName = "${TAG}.signOut()"
)

val account: IAccount =
Expand Down Expand Up @@ -220,7 +220,7 @@ class AccountState private constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "$TAG.getAccessToken"
methodName = "${TAG}.getAccessToken(forceRefresh: Boolean = ${forceRefresh}, callback: GetAccessTokenCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -278,7 +278,7 @@ class AccountState private constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "$TAG.getAccessToken"
methodName = "${TAG}.getAccessToken(forceRefresh: Boolean = ${forceRefresh}, scopes: List<String>, callback: GetAccessTokenCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand All @@ -295,7 +295,7 @@ class AccountState private constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = null,
methodName = "$TAG.getAccessToken(forceRefresh: Boolean)"
methodName = "${TAG}.getAccessTokenInternal(forceRefresh: Boolean = ${forceRefresh}, scopes: List<String>)"
)

return withContext(Dispatchers.IO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ResetPasswordCodeRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitCode"
methodName = "${TAG}.submitCode(code: String, callback: SubmitCodeCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -357,7 +357,7 @@ class ResetPasswordPasswordRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitPassword"
methodName = "${TAG}.submitPassword(password: CharArray, callback: SubmitPasswordCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class SignInCodeRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitCode"
methodName = "${TAG}.submitCode(code: String, callback: SubmitCodeCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -223,7 +223,7 @@ class SignInCodeRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.resendCode"
methodName = "${TAG}.resendCode(callback: ResendCodeCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -369,7 +369,7 @@ class SignInPasswordRequiredState(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitPassword"
methodName = "${TAG}.submitPassword(password: CharArray, callback: SubmitPasswordCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -531,7 +531,7 @@ class SignInContinuationState(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.signIn"
methodName = "${TAG}.signIn(scopes: List<String>, callback: SignInContinuationCallback)"
)

NativeAuthPublicClientApplication.pcaScope.launch {
Expand All @@ -552,6 +552,12 @@ class SignInContinuationState(
* @return The results of the sign-in-after-sign-up action.
*/
suspend fun signIn(scopes: List<String>? = null): SignInResult {
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.signIn(scopes: List<String>)"
)

return withContext(Dispatchers.IO) {
try {
LogSession.logMethodCall(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SignUpCodeRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitCode"
methodName = "${TAG}.submitCode(code: String, callback: SubmitCodeCallback)"
)

NativeAuthPublicClientApplication.pcaScope.launch {
Expand Down Expand Up @@ -258,7 +258,7 @@ class SignUpCodeRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.resendCode"
methodName = "${TAG}.resendCode(callback: SignUpWithResendCodeCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -403,7 +403,7 @@ class SignUpPasswordRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitPassword"
methodName = "${TAG}.submitPassword(password: CharArray, callback: SignUpSubmitPasswordCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down Expand Up @@ -613,7 +613,7 @@ class SignUpAttributesRequiredState internal constructor(
LogSession.logMethodCall(
tag = TAG,
correlationId = correlationId,
methodName = "${TAG}.submitAttributes"
methodName = "${TAG}.submitAttributes(attributes: UserAttributes, callback: SignUpSubmitUserAttributesCallback)"
)
NativeAuthPublicClientApplication.pcaScope.launch {
try {
Expand Down
Loading