Skip to content

Commit

Permalink
Merge branch 'main' of github.com:spatie/spatie.be
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 23, 2024
2 parents 9c772f0 + 1a443d6 commit cf13844
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 329 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
11 changes: 9 additions & 2 deletions app/Console/Commands/AfterworkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Illuminate\Console\Command;
use Spatie\Holidays\Holidays;
use Spatie\SlackAlerts\Facades\SlackAlert;

class AfterworkCommand extends Command
Expand All @@ -20,7 +21,9 @@ public function handle(): void
->map(fn (string $option, int $index) => $this->addEmoji($option, $index))
->implode("\n");

SlackAlert::message("Who is in for an afterwork drink? :beer: :cup_with_straw:\n{$options}");
$this->info("Poll options:\n{$options}");

SlackAlert::message("Who is in for an afterwork drink? :beer:\n{$options}");

$this->info('Poll posted to Slack');
}
Expand All @@ -33,6 +36,10 @@ protected function generatePollOptions(): array
$datesInMonth = $this->getDatesForWeekdayInMonth($weekday);

foreach ($datesInMonth as $date) {
if (Holidays::for('be')->isHoliday($date)) {
continue;
}

$options[$date->day] = "{$date->shortDayName} {$date->day}/{$date->month}";
}
}
Expand All @@ -56,7 +63,7 @@ protected function getDatesForWeekdayInMonth(string $dayName): CarbonPeriod
return new CarbonPeriod(
CarbonImmutable::parse("first {$dayName} of this month"),
CarbonInterval::week(),
CarbonImmutable::parse("first {$dayName} of next month")
CarbonImmutable::parse("first {$dayName} of next month")->subDay(),
);
}

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
9 changes: 0 additions & 9 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
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;
use Laravel\Socialite\Facades\Socialite;

class AuthServiceProvider extends ServiceProvider
{
Expand All @@ -30,12 +28,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.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"spatie/crypto": "^2.0.1",
"spatie/eloquent-sortable": "^4.0.1",
"spatie/fork": "^1.1.2",
"spatie/holidays": "^1.0",
"spatie/laravel-artisan-dispatchable": "^1.3",
"spatie/laravel-backup": "^8.1.5",
"spatie/laravel-comments": "^1.3",
Expand Down
Loading

0 comments on commit cf13844

Please sign in to comment.