-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add native auth to MSAL test app #2001
Changes from 8 commits
16c8edd
867257d
ddb1f2c
fc9b579
179806d
e82f257
805cd74
609e85b
dd05327
288bf19
42c8452
f6cf2ee
6e088ce
39b5130
bcb755d
dbb5f0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,14 @@ | |
|
||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'kotlin-android-extensions' | ||
|
||
|
||
def msalVersion = "5.0.0" | ||
|
||
|
||
if (project.hasProperty("distMsalVersion")) { | ||
msalVersion = distMsalVersion | ||
} | ||
|
@@ -83,6 +89,9 @@ android { | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
buildFeatures { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? and why is it needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://developer.android.com/topic/libraries/view-binding
It's a much improved process of managing view (interactions, etc.) that has been rolled out by Android for quite some time. New and improved way of doing things. |
||
viewBinding true | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
|
@@ -111,6 +120,8 @@ dependencies { | |
localImplementation project(':msal') | ||
distImplementation "com.microsoft.identity.client:msal:${msalVersion}" | ||
implementation "com.google.code.gson:gson:$rootProject.ext.gsonVersion" | ||
implementation "androidx.constraintlayout:constraintlayout:$rootProject.ext.constraintLayoutVersion" | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinXCoroutinesVersion" | ||
implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatVersion" | ||
Yuki-YuXin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implementation "androidx.legacy:legacy-support-v4:$rootProject.ext.legacySupportV4Version" | ||
implementation "com.google.android.material:material:$rootProject.ext.materialVersion" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
package com.microsoft.identity.client.testapp | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import com.google.android.material.bottomnavigation.BottomNavigationView | ||
import com.microsoft.identity.client.testapp.nativeauth.AuthClient | ||
import com.microsoft.identity.client.testapp.nativeauth.EmailAttributeSignUpFragment | ||
import com.microsoft.identity.client.testapp.nativeauth.EmailPasswordSignInSignUpFragment | ||
import com.microsoft.identity.client.testapp.nativeauth.EmailSignInSignUpFragment | ||
import com.microsoft.identity.client.testapp.nativeauth.PasswordResetFragment | ||
|
||
class NativeAuthFragment : Fragment() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. javadoc on all classes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't see javadoc on this particular class though |
||
companion object { | ||
private val TAG = MainActivity::class.java.simpleName | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
val view = inflater.inflate(R.layout.fragment_native, container, false) | ||
|
||
AuthClient.initialize(requireContext()) | ||
|
||
val emailSignInSignUpFragment = EmailSignInSignUpFragment() | ||
val emailPasswordSignInSignUpFragment = EmailPasswordSignInSignUpFragment() | ||
val emailAttributeSignUpFragment = EmailAttributeSignUpFragment() | ||
val passwordResetFragment = PasswordResetFragment() | ||
|
||
val bottomNavigationView = view.findViewById<BottomNavigationView>(R.id.bottom_navigation_view) | ||
|
||
setFragment(emailSignInSignUpFragment, R.string.title_email_oob_sisu) | ||
|
||
bottomNavigationView.setOnNavigationItemSelectedListener { | ||
when (it.itemId) { | ||
R.id.email_oob_sisu -> setFragment(emailSignInSignUpFragment, R.string.title_email_oob_sisu) | ||
R.id.email_password_sisu -> setFragment(emailPasswordSignInSignUpFragment, R.string.title_email_password_sisu) | ||
R.id.email_attribute_sisu -> setFragment(emailAttributeSignUpFragment, R.string.title_email_attribute_oob_sisu) | ||
R.id.email_oob_sspr -> setFragment(passwordResetFragment, R.string.title_email_oob_sspr) | ||
} | ||
true | ||
} | ||
|
||
return view | ||
} | ||
|
||
private fun setFragment(fragment: Fragment, title: Int) { | ||
(this.context as AppCompatActivity).supportFragmentManager.beginTransaction().apply { | ||
replace(R.id.scenario_fragment, fragment) | ||
commit() | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new line ending; here and everywhere |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
package com.microsoft.identity.client.testapp.nativeauth | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import com.microsoft.identity.client.PublicClientApplication | ||
import com.microsoft.identity.client.testapp.R | ||
import com.microsoft.identity.nativeauth.INativeAuthPublicClientApplication | ||
|
||
object AuthClient : Application() { | ||
private lateinit var authClient: INativeAuthPublicClientApplication | ||
|
||
fun getAuthClient(): INativeAuthPublicClientApplication { | ||
return authClient | ||
} | ||
|
||
fun initialize(context: Context) { | ||
authClient = PublicClientApplication.createNativeAuthPublicClientApplication( | ||
context, | ||
R.raw.msal_config_native | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
package com.microsoft.identity.client.testapp.nativeauth | ||
|
||
interface Constants { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. javadoc everywhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed |
||
companion object { | ||
const val STATE = "state" | ||
const val CODE_LENGTH = "code_length" | ||
const val SENT_TO = "sent_to" | ||
const val CHANNEL = "channel" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be able to test the proguard rules in the dist variant of the test app now, since we incorporate native auth into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yuki-YuXin this is because test app is pulling an outdated MSAL version (4.x), one that doesn't have native auth included yet. I'll update this in the PR.