Skip to content

Commit

Permalink
Remove apple login
Browse files Browse the repository at this point in the history
  • Loading branch information
riasvdv committed Jan 3, 2024
1 parent dbac84b commit d81ed8a
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 283 deletions.
39 changes: 0 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,6 @@ If you'd like to reuse or repost something, feel free to hit us up at info@spati

This project and the Laravel framework are open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

## Apple sign-in

Every 6 months, the token for Sign-in with Apple expires, this can be renewed using the "Spatie apple login - private key" in our team's 1Password vault and the following ruby script:

```ruby
require 'jwt'

key_file = 'key.txt'
team_id = '' # Found in the top right when signed in on the Apple developer site
client_id = 'be.spatie.website'
key_id = '' # The key ID, found here https://developer.apple.com/account/resources/authkeys/list

ecdsa_key = OpenSSL::PKey::EC.new IO.read key_file

headers = {
'kid' => key_id
}

claims = {
'iss' => team_id,
'iat' => Time.now.to_i,
'exp' => Time.now.to_i + 86400*180,
'aud' => 'https://appleid.apple.com',
'sub' => client_id,
}

token = JWT.encode claims, ecdsa_key, 'ES256', headers

puts token
```

Then execute it using

```shell
ruby client_secret.rb
```

Which gives you a new token that is valid for 6 months.

## GeoIP lookup

We use Maxmind's geo IP dataset to provide PPP based on IP location. This is built using the excellent [laravel-geoip](https://lyften.com/projects/laravel-geoip) package.
Expand Down
74 changes: 0 additions & 74 deletions app/Http/Controllers/AppleSocialiteController.php

This file was deleted.

11 changes: 0 additions & 11 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ public function disconnect(): RedirectResponse
return redirect()->route('profile');
}

public function disconnectApple(): RedirectResponse
{
auth()->user()->update([
'apple_id' => null,
]);

flash()->success('Apple account disconnected.');

return redirect()->route('profile');
}

public function delete(): RedirectResponse
{
/** @var \App\Models\User $user */
Expand Down
8 changes: 0 additions & 8 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Providers;

use App\Domain\Shop\Models\License;
use App\Support\Socialite\SignInWithAppleProvider;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand All @@ -30,12 +29,5 @@ public function boot(): void

return $license;
});

Socialite::extend('apple', function () {
return Socialite::buildProvider(
SignInWithAppleProvider::class,
config('services.apple'),
);
});
}
}
89 changes: 0 additions & 89 deletions app/Support/Socialite/SignInWithAppleProvider.php

This file was deleted.

6 changes: 0 additions & 6 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@
'package_training' => env('PROMO_CODE_PACKAGE_TRAINING'),
],

'apple' => [
'redirect' => env('APPLE_CALLBACK_URL'),
'client_id' => env('APPLE_ID'),
'client_secret' => env('APPLE_SECRET'),
],

'mailcoach' => [
'token' => env('MAILCOACH_TOKEN'),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('apple_id');
});
}
};
22 changes: 0 additions & 22 deletions resources/views/auth/appleCallback.blade.php

This file was deleted.

10 changes: 0 additions & 10 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ function showGitHubAuthWindow() {
</x-button>
</a>
</div>
<div>
<a href="{{ route('apple-login') }}">
<x-button>
<span class="-ml-3 mr-3 icon w-4 mb-1 opacity">
{{ svg('apple') }}
</span>
Sign-in with Apple
</x-button>
</a>
</div>
</div>

<h3 class="mt-12 title-sm -mb-2">
Expand Down
18 changes: 0 additions & 18 deletions resources/views/front/profile/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@
<p class="mt-1 text-sm text-gray">Log in without password and check your sponsor status.</p>
@endif
</div>
<div class="mt-4">
@if (auth()->user()->apple_id)
<span class="flex items-center">
<span class="icon fill-current w-4 mr-2">
{{ svg('apple') }}
</span>
<a class="ml-4 link-blue link-underline" href="{{ route('apple-disconnect') }}">Disconnect from Sign-in with Apple</a>
</span>
@else
<a class="link-blue link-underline flex items-center" href="{{ route('apple-login') }}">
<span class="icon fill-current w-4 mr-2">
{{ svg('apple') }}
</span>
Connect to Sign-in with Apple
</a>
<p class="mt-1 text-sm text-gray">Log in without password.</p>
@endif
</div>
</div>
</section>

Expand Down
6 changes: 0 additions & 6 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
use App\Http\Auth\Controllers\ResetPasswordController;
use App\Http\Auth\Controllers\UpdatePasswordController;
use App\Http\Controllers\AfterPaddleBundleSaleController;
use App\Http\Controllers\AppleSocialiteController;
use App\Http\Controllers\BlogsController;
use App\Http\Controllers\BundlesController;
use App\Http\Controllers\DocsController;
use App\Http\Controllers\DownloadLatestReleaseForExpiredLicenseController;
use App\Http\Controllers\DownloadPurchasableController;
use App\Http\Controllers\DownloadRayController;
use App\Http\Controllers\MusicController;
use App\Http\Controllers\ReadablePhpController;
use App\Http\Controllers\ShowReleaseNotesController;
use App\Http\Controllers\GitHubSocialiteController;
use App\Http\Controllers\GuidelinesController;
Expand Down Expand Up @@ -122,7 +120,6 @@
Route::get('/', [ProfileController::class, 'show'])->name('profile');
Route::put('/', [ProfileController::class, 'update'])->name('profile');
Route::get('disconnect', [ProfileController::class, 'disconnect'])->name('github-disconnect');
Route::get('disconnect-apple', [ProfileController::class, 'disconnectApple'])->name('apple-disconnect');
Route::delete('/', [ProfileController::class, 'delete'])->name('profile');

Route::get('password', [UpdatePasswordController::class, 'show'])->name('profile.password');
Expand All @@ -146,9 +143,6 @@
Route::get('login/github', [GitHubSocialiteController::class, 'redirect'])->name('github-login');
Route::get('login/github/callback', [GitHubSocialiteController::class, 'callback']);

Route::get('login/apple', [AppleSocialiteController::class, 'redirect'])->name('apple-login');
Route::post('login/apple', [AppleSocialiteController::class, 'callback']);

Route::post('logout', [LogoutController::class, 'logout'])->name('logout');

Route::get('/courses', [CoursesController::class, 'index'])->name('courses.index');
Expand Down

0 comments on commit d81ed8a

Please sign in to comment.