Skip to content

Commit

Permalink
change default PKCE to always enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Jul 27, 2016
1 parent 784e93b commit b35f5d3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/src/main/res/layout/demo_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="Use Webview" />
android:text="Use Browser" />

<RadioButton
android:id="@+id/radio_use_webview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Use Browser" />
android:text="Use WebView" />
</RadioGroup>

<CheckBox
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/com/auth0/android/lock/Lock.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public Builder useBrowser(boolean useBrowser) {

/**
* Whether to use PKCE or the implicit token grant when performing calls to /authenticate.
* Default is {@code false}
* Default is {@code true}
*
* @param usePKCE if Lock will use PKCE instead of the implicit token grant.
* @return the current Builder instance
Expand Down
1 change: 1 addition & 0 deletions lib/src/main/java/com/auth0/android/lock/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public Options() {
allowForgotPassword = true;
loginAfterSignUp = true;
useCodePasswordless = true;
usePKCE = true;
authenticationParameters = new HashMap<>();
customFields = new ArrayList<>();
theme = Theme.newBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public Builder useBrowser(boolean useBrowser) {

/**
* Whether to use PKCE or the implicit token grant when performing calls to /authenticate.
* Default is {@code false}
* Default is {@code true}
*
* @param usePKCE if Lock will use PKCE instead of the implicit token grant.
* @return the current Builder instance
Expand Down
36 changes: 33 additions & 3 deletions lib/src/test/java/com/auth0/android/lock/OptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,21 @@ public void shouldUseSmallSocialButtonStyle() {
}

@Test
public void shouldUsePKCE() {
public void shouldHavePKCEEnabledByDefault() {
Options options = new Options();
options.setAccount(auth0);

Parcel parcel = Parcel.obtain();
options.writeToParcel(parcel, 0);
parcel.setDataPosition(0);

Options parceledOptions = Options.CREATOR.createFromParcel(parcel);
assertThat(options.usePKCE(), is(true));
assertThat(parceledOptions.usePKCE(), is(true));
}

@Test
public void shouldEnablePKCE() {
Options options = new Options();
options.setAccount(auth0);
options.setUsePKCE(true);
Expand All @@ -116,7 +130,23 @@ public void shouldUsePKCE() {
parcel.setDataPosition(0);

Options parceledOptions = Options.CREATOR.createFromParcel(parcel);
assertThat(options.usePKCE(), is(equalTo(parceledOptions.usePKCE())));
assertThat(options.usePKCE(), is(true));
assertThat(parceledOptions.usePKCE(), is(true));
}

@Test
public void shouldDisablePKCE() {
Options options = new Options();
options.setAccount(auth0);
options.setUsePKCE(false);

Parcel parcel = Parcel.obtain();
options.writeToParcel(parcel, 0);
parcel.setDataPosition(0);

Options parceledOptions = Options.CREATOR.createFromParcel(parcel);
assertThat(options.usePKCE(), is(false));
assertThat(parceledOptions.usePKCE(), is(false));
}

@Test
Expand Down Expand Up @@ -486,7 +516,7 @@ public void shouldSetDefaultValues() {
Options parceledOptions = Options.CREATOR.createFromParcel(parcel);
assertTrue(options != parceledOptions); //assure correct Parcelable object testing
assertThat(options.useBrowser(), is(false));
assertThat(options.usePKCE(), is(false));
assertThat(options.usePKCE(), is(true));
assertThat(options.allowLogIn(), is(true));
assertThat(options.allowSignUp(), is(true));
assertThat(options.allowForgotPassword(), is(true));
Expand Down

0 comments on commit b35f5d3

Please sign in to comment.