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

feat: Handle OIDC login by email and by OIDC #98

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .github/resources/export-options-app-store.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>provisioningProfiles</key>
<dict>
<key>io.cozy.pass.mobile</key>
<string>Cozy Pass Distribution Profile</string>
<key>io.cozy.pass.mobile.autofill</key>
<string>Cozy Pass Autofill Distribution Profile</string>
<key>io.cozy.pass.mobile.find-login-action-extension</key>
<string>Cozy Pass Find Login Action Distribution Profile</string>
<key>io.cozy.pass.mobile.share-extension</key>
<string>Cozy Pass Share Extension Distribution Profile</string>
</dict>
</dict>
</plist>
129 changes: 129 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
name: Build

on:
workflow_dispatch:
pull_request:

jobs:
ios:
name: Apple iOS
runs-on: macos-14
steps:
- run: brew install --cask xamarin-ios
name: 'Install Xamarin.iOS package using Homebrew'

- run: brew install --cask xamarin-android
name: 'Install Xamarin.Android package using Homebrew'

- name: Setup NuGet
uses: nuget/setup-nuget@296fd3ccf8528660c91106efefe2364482f86d6f # v1.2.0
with:
nuget-version: 6.4.0

- name: Print environment
run: |
nuget help | grep Version
msbuild -version
dotnet --info
echo "GitHub ref: $GITHUB_REF"
echo "GitHub event: $GITHUB_EVENT"

- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'true'

- name: Set up Keychain
env:
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
DIST_CERT_PASSWORD: ${{ secrets.IOS_DIST_CERT_P12_PASSWORD }}
run: |
mkdir -p $HOME/secrets
echo ${{ secrets.IOS_DIST_CERT_P12_BASE64 }} | base64 --decode > $HOME/secrets/iphone-distribution-cert.p12
echo ${{ secrets.IOS_AUTOFILL_PROFILE_BASE_64 }} | base64 --decode > $HOME/secrets/Cozy_Pass_Autofill_Distribution_Profile.mobileprovision
echo ${{ secrets.IOS_APP_PROFILE_BASE_64 }} | base64 --decode > $HOME/secrets/Cozy_Pass_Distribution_Profile.mobileprovision
echo ${{ secrets.IOS_EXTENSION_PROFILE_BASE_64 }} | base64 --decode > $HOME/secrets/Cozy_Pass_Find_Login_Action_Distribution_Profile.mobileprovision
echo ${{ secrets.IOS_SHARE_EXTENSION_PROFILE_BASE_64 }} | base64 --decode > $HOME/secrets/Cozy_Pass_Share_Extension_Distribution_Profile.mobileprovision
security create-keychain -p $KEYCHAIN_PASSWORD build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $KEYCHAIN_PASSWORD build.keychain
security set-keychain-settings -lut 1200 build.keychain
security import ~/secrets/iphone-distribution-cert.p12 -k build.keychain -P $DIST_CERT_PASSWORD \
-T /usr/bin/codesign -T /usr/bin/security
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $KEYCHAIN_PASSWORD build.keychain

- name: Set up provisioning profiles
run: |
AUTOFILL_PROFILE_PATH=$HOME/secrets/Cozy_Pass_Autofill_Distribution_Profile.mobileprovision
BITWARDEN_PROFILE_PATH=$HOME/secrets/Cozy_Pass_Distribution_Profile.mobileprovision
EXTENSION_PROFILE_PATH=$HOME/secrets/Cozy_Pass_Find_Login_Action_Distribution_Profile.mobileprovision
SHARE_EXTENSION_PROFILE_PATH=$HOME/secrets/Cozy_Pass_Share_Extension_Distribution_Profile.mobileprovision
PROFILES_DIR_PATH=$HOME/Library/MobileDevice/Provisioning\ Profiles

mkdir -p "$PROFILES_DIR_PATH"

AUTOFILL_UUID=$(grep UUID -A1 -a $AUTOFILL_PROFILE_PATH | grep -io "[-A-F0-9]\{36\}")
cp $AUTOFILL_PROFILE_PATH "$PROFILES_DIR_PATH/$AUTOFILL_UUID.mobileprovision"

BITWARDEN_UUID=$(grep UUID -A1 -a $BITWARDEN_PROFILE_PATH | grep -io "[-A-F0-9]\{36\}")
cp $BITWARDEN_PROFILE_PATH "$PROFILES_DIR_PATH/$BITWARDEN_UUID.mobileprovision"

EXTENSION_UUID=$(grep UUID -A1 -a $EXTENSION_PROFILE_PATH | grep -io "[-A-F0-9]\{36\}")
cp $EXTENSION_PROFILE_PATH "$PROFILES_DIR_PATH/$EXTENSION_UUID.mobileprovision"

SHARE_EXTENSION_UUID=$(grep UUID -A1 -a $SHARE_EXTENSION_PROFILE_PATH | grep -io "[-A-F0-9]\{36\}")
cp $SHARE_EXTENSION_PROFILE_PATH "$PROFILES_DIR_PATH/$SHARE_EXTENSION_UUID.mobileprovision"

- name: Restore packages
run: nuget restore

- name: Archive Build for App Store
run: |
$configuration = "AppStore";
$platform = "iPhone";

Write-Output "########################################"
Write-Output "##### Archive $configuration Configuration for $platform Platform"
Write-Output "########################################"
msbuild "$($env:GITHUB_WORKSPACE + "/src/iOS/iOS.csproj")" "/p:Platform=$platform" `
"/p:Configuration=$configuration" "/p:ArchiveOnBuild=true" "/t:`"Build`""

Write-Output "########################################"
Write-Output "##### Done"
Write-Output "########################################"
shell: pwsh

- name: Export .ipa for App Store
run: |
EXPORT_OPTIONS_PATH="./.github/resources/export-options-app-store.plist"
ARCHIVE_PATH="$HOME/Library/Developer/Xcode/Archives/*/*.xcarchive"
EXPORT_PATH="./bitwarden-export"

xcodebuild -exportArchive -archivePath $ARCHIVE_PATH -exportPath $EXPORT_PATH \
-exportOptionsPlist $EXPORT_OPTIONS_PATH

ls $EXPORT_PATH

- name: Upload App Store .ipa
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: Bitwarden iOS
path: |
./bitwarden-export/*.ipa
if-no-files-found: error

# - name: Deploy to App Store
# if: |
# (github.ref == 'refs/heads/main'
# && needs.setup.outputs.rc_branch_exists == 0
# && needs.setup.outputs.hotfix_branch_exists == 0)
# || (github.ref == 'refs/heads/rc' && needs.setup.outputs.hotfix_branch_exists == 0)
# || github.ref == 'refs/heads/hotfix-rc'
# env:
# APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }}
# APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
# run: |
# xcrun altool --upload-app --type ios --file "./bitwarden-export/Bitwarden.ipa" \
# --username "$APPLE_ID_USERNAME" --password "$APPLE_ID_PASSWORD"

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# 3.0.7

## ✨ Features


## 🐛 Bug Fixes


## 🔧 Tech


# 3.0.6

## ✨ Features

* Add support for Android 13 clipboard management ([PR #93](https://github.com/cozy/cozy-pass-mobile/pull/93))

## 🐛 Bug Fixes

* Fix login by email to make it work on Firefox browsers ([PR #95](https://github.com/cozy/cozy-pass-mobile/pull/95))

## 🔧 Tech

* Change Android TargetSDK for 33 ([PR #93](https://github.com/cozy/cozy-pass-mobile/pull/93))

# 3.0.5

Expand Down
4 changes: 2 additions & 2 deletions src/Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="3000501"
android:versionName="3.0.5"
android:versionCode="3000602"
android:versionName="3.0.6"
android:installLocation="internalOnly"
package="io.cozy.pass">

Expand Down
28 changes: 28 additions & 0 deletions src/App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
using Bit.Core;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Flurl;
using System;
using System.Threading.Tasks;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

Expand Down Expand Up @@ -204,6 +206,16 @@ public async Task HandleLoginLink(string fqdn)
await Current.MainPage.Navigation.PushModalAsync(new NavigationPage(page));
}

public async Task HandleManagerLink(string managerLink)
{
await Browser.OpenAsync(managerLink, new BrowserLaunchOptions
{
LaunchMode = BrowserLaunchMode.SystemPreferred,
TitleMode = BrowserTitleMode.Show,
Flags = BrowserLaunchFlags.PresentAsPageSheet
});
}

public async Task HandleOnboardingLink(string onboardingUrl)
{
var page = new CozyNoOnboardingPage();
Expand All @@ -224,6 +236,22 @@ protected override async void OnAppLinkRequestReceived(Uri uri)

var localPath = uri.LocalPath.StartsWith("/pass") ? uri.LocalPath.Replace("/pass", "") : uri.LocalPath;

if ((localPath == "/manager"))
{
var fallback = queryDictionary.Get("fallback");
var fallbackUrl = new Uri(fallback);
var fallbackQueryDictionary = System.Web.HttpUtility.ParseQueryString(fallbackUrl.Query);
var fallbackFqdn = fallbackQueryDictionary.Get("fqdn");

if (!string.IsNullOrEmpty(fallbackFqdn))
{
await HandleLoginLink(fallbackFqdn);
} else
{
await HandleManagerLink(fallback);
}
}

if ((localPath == "/login" || localPath == "/onboarding") && !string.IsNullOrEmpty(fqdn))
{
await HandleLoginLink(fqdn);
Expand Down
3 changes: 3 additions & 0 deletions src/App/Pages/Vault/AddEditPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public AddEditPageViewModel()
{
new KeyValuePair<string, CipherType>(AppResources.TypeLogin, CipherType.Login),
new KeyValuePair<string, CipherType>(AppResources.TypeCard, CipherType.Card),
// Cozy Customization, Prevent to create Profiles as they will be replaced by Cozy Contacts
/*
new KeyValuePair<string, CipherType>(AppResources.TypeIdentity, CipherType.Identity)
//*/
};
CardBrandOptions = new List<KeyValuePair<string, string>>
{
Expand Down
9 changes: 9 additions & 0 deletions src/App/Pages/Vault/ViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ private void AdjustToolbar()
{
ToolbarItems.Insert(1, _editItem);
}
// Cozy customization, Prevent to restore/edit/clone/move Profiles as they will be replaced by Cozy Contacts
//*
if (_vm.Cipher.Type == Core.Enums.CipherType.Identity)
{
ToolbarItems.Remove(_editItem);
ToolbarItems.Remove(_cloneItem);
ToolbarItems.Remove(_shareItem);
}
//*/
}
}
}
2 changes: 1 addition & 1 deletion src/App/Pages/Vault/ViewPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public bool TotpLow
}
}
public bool IsDeleted => Cipher.IsDeleted;
public bool CanEdit => !Cipher.IsDeleted;
public bool CanEdit => !Cipher.IsDeleted && Cipher.Type != CipherType.Identity;

// Cozy customization, display folder (Cozy concept)
//*
Expand Down
6 changes: 6 additions & 0 deletions src/App/Utilities/AppHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ public static async Task<string> CipherListOptions(ContentPage page, CipherView
var clipboardService = ServiceContainer.Resolve<IClipboardService>("clipboardService");

var options = new List<string> { AppResources.View };

// Cozy customization, Prevent to edit Profiles as they will be replaced by Cozy Contacts
/*
if (!cipher.IsDeleted)
/*/
if (!cipher.IsDeleted && cipher.Type != CipherType.Identity)
//*/
{
options.Add(AppResources.Edit);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Services/CozyClouderyEnvService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.Core.Abstractions;
using Flurl;
Expand All @@ -17,7 +17,7 @@ public class CozyClouderyEnvService: ICozyClouderyEnvService

private const string LOGIN_RELATIVE_URI = "/v2/neutral/start";

private const string QUERY_STRING = "redirect_after_email=https%3A%2F%2Flinks.mycozy.cloud%2Fpass%2Fonboarding%3Ffallback%3Dcozypass%253A%252F%252Fpass%252Fonboarding&redirect_after_login=cozypass%3A%2F%2Fpass%2Flogin";
private const string QUERY_STRING = "app_will_ask_password=true&universallink_for_email=https%3A%2F%2Flinks.mycozy.cloud%2Fpass%2Fmanager&redirect_after_email=https%3A%2F%2Flinks.mycozy.cloud%2Fpass%2Fonboarding%3Ffallback%3Dcozypass%253A%252F%252Fpass%252Fonboarding&redirect_after_login=cozypass%3A%2F%2Fpass%2Flogin";

private readonly IStorageService _storageService;

Expand Down
4 changes: 2 additions & 2 deletions src/iOS.Autofill/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleIdentifier</key>
<string>io.cozy.pass.mobile.autofill</string>
<key>CFBundleShortVersionString</key>
<string>3.0.5</string>
<string>3.0.6</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
Expand Down Expand Up @@ -96,6 +96,6 @@
</dict>
</dict>
<key>CFBundleVersion</key>
<string>3000501</string>
<string>3000603</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions src/iOS.Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleIdentifier</key>
<string>io.cozy.pass.mobile.find-login-action-extension</string>
<key>CFBundleShortVersionString</key>
<string>3.0.5</string>
<string>3.0.6</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
Expand Down Expand Up @@ -113,6 +113,6 @@
<string>com.apple.ui-services</string>
</dict>
<key>CFBundleVersion</key>
<string>3000501</string>
<string>3000603</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions src/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleIdentifier</key>
<string>io.cozy.pass.mobile</string>
<key>CFBundleShortVersionString</key>
<string>3.0.5</string>
<string>3.0.6</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -137,6 +137,6 @@
</dict>
</dict>
<key>CFBundleVersion</key>
<string>3000501</string>
<string>3000603</string>
</dict>
</plist>
Loading