Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Butcher committed Dec 26, 2020
0 parents commit e742e74
Show file tree
Hide file tree
Showing 69 changed files with 2,742 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
* text=auto

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
/tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.styleci.yml export-ignore
CHANGELOG.md export-ignore
phpunit.xml.dist export-ignore
UPGRADE.md export-ignore
Binary file added .github/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: tests

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
tests:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4, 8.0]
laravel: [^8.0]

name: P${{ matrix.php }} - L${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: |
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --verbose
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/vendor
composer.lock
/phpunit.xml
.phpunit.result.cache
4 changes: 4 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
php:
preset: laravel
disabled:
- no_unused_imports
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Release Notes
# Changelog

This changelog follows [the Keep a Changelog standard](https://keepachangelog.com).

## [Unreleased](https://github.com/blade-ui-kit/blade-ui-kit/compare/0.2.0...0.x)
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Joel Butcher

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.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Socialstream

<p align="center">
<a href="https://github.com/joelbutcher/socialstream/actions">
<img src="https://github.com/joelbutcher/socialstream/workflows/tests/badge.svg" alt="Build Status">
</a>
<a href="https://packagist.org/packages/joelbutcher/socialstream">
<img src="https://img.shields.io/packagist/dt/joelbutcher/socialstream" alt="Total Downloads">
</a>
<a href="https://packagist.org/packages/joelbutcher/socialstream">
<img src="https://img.shields.io/packagist/v/joelbutcher/socialstream" alt="Latest Stable Version">
</a>
<a href="https://packagist.org/packages/joelbutcher/socialstream">
<img src="https://img.shields.io/packagist/l/joelbutcher/socialstream" alt="License">
</a>
</p>

## Introduction

Socialstream is a third-party package for [Laravel Jetstream](https://github.com/laravel/jetstream). It replaces the published authentication and profile scaffolding provided by Laravel Jetstream, with scaffolding that has support for [Laravel Socialite](https://laravel.com/docs/8.x/socialite).

If you are unfamiliar with Laravel Socialite, it is strongly advised that you take a look at the [official documentation](https://laravel.com/docs/8.x/socialite).

## Installation

Getting started with Socialstream is a breeze. With a simple two-step process to get you on your way to creating the next big thing. Inspired by the simplicity of Jetstream's installation process, Socialstream follows the same 'installation':

```sh
composer require joelbutcher/socialstream

php artisan socialstream:install
```

The `socialstream:install` command will overwrite the Jetstream publushed files which are required for Socialstream to work.

> Note: If you don't have Laravel Jetstream installed, the above command will walk you through the steps required to install it.
## Socialite Providers

If you wish to use the community driven [socialiteproviders](https://socialiteproviders.com) package with Socialstream, you may do so by following their documentation on installing the package into a Laravel project. There are a few configuration steps you will need to go through first.

To implement a custom provider, you will need to create an SVG icon file (e.g. `twitter-icon.blade.php` or `TwitterIcon.vue`) to be used in the authentication cards and the account management panel.

You will then need to alter the appropriate published components with your new icons and provider condition:

- Connected Account component
- Socialstream Providers component

## Changelog

Check out the [CHANGELOG](CHANGELOG.md) in this repository for all the recent changes.

## Maintainers

Socialstream is developed and maintained by [Joel Butcher](https://joelbutcher.co.uk)

## License

Socialstream is open-sourced software licensed under the [MIT license](LICENSE.md).
52 changes: 52 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "joelbutcher/socialstream",
"description": "A simple Socialite implementation for Laravel Jetstream.",
"keywords": ["laravel", "tailwind", "auth"],
"license": "MIT",
"support": {
"issues": "https://github.com/laravel/jetstream/issues",
"source": "https://github.com/laravel/jetstream"
},
"authors": [
{
"name": "Joel Butcher",
"email": "[email protected]"
}
],
"require": {
"php": "^7.3|^8.0",
"illuminate/support": "^8.0",
"laravel/jetstream": "^1.0|^2.0",
"laravel/socialite": "^5.0"
},
"require-dev": {
"inertiajs/inertia-laravel": "^0.3",
"laravel/sanctum": "^2.6",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
"JoelButcher\\Socialstream\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"JoelButcher\\Socialstream\\Tests\\": "tests/",
"App\\": "stubs/app/"
}
},
"extra": {
"laravel": {
"providers": [
"JoelButcher\\Socialstream\\SocialstreamServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
51 changes: 51 additions & 0 deletions config/socialstream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Socialstream Visibility
|--------------------------------------------------------------------------
|
| This value is used to determine whether or not to show the providers
| on "/login" or "/register" routes.
|
| Note: if you have previously enabled socialstream, and have users in
| your database with any connected accounts, they will still be able to
| disconnect them from their profile.
|
*/

'show' => env('SHOW_SOCIALSTREAM', true),

/*
|--------------------------------------------------------------------------
| Socialstream Route Middleware
|--------------------------------------------------------------------------
|
| Here you may specify which middleware Socialstream will assign to the
| routes that it registers with the application. When necessary, you may
| modify these middleware; however, this default value is usually sufficient.
|
*/

'middleware' => ['web'],

/*
|--------------------------------------------------------------------------
| Socialstream Providers
|--------------------------------------------------------------------------
|
| Here you may specify the providers your application supports for OAuth.
| Out of the box, Socialstream provides support for all of the OAuth
| providers that are supported by Laravel Socialite.
|
| Supported: "google", "facebook", "github", "gitlab",
| "bitbucket", "linkedin", "twitter"
|
*/

'providers' => [
// 'github',
],
];
39 changes: 39 additions & 0 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Laravel\Jetstream\Features;

class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
$table->foreignId('current_team_id')->nullable();
$table->text('profile_photo_path')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

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

class CreateConnectedAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('connected_accounts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id');
$table->string('provider_name');
$table->string('provider_id');
$table->string('token');
$table->string('secret')->nullable(); // OAuth1
$table->string('refresh_token')->nullable(); // OAuth2
$table->dateTime('expires_at')->nullable(); // OAuth2
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('connected_accounts');
}
}
20 changes: 20 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Socialstream Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
</phpunit>
18 changes: 18 additions & 0 deletions routes/socialstream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Illuminate\Support\Facades\Route;
use JoelButcher\Socialstream\Http\Controllers\Inertia\PasswordController;
use JoelButcher\Socialstream\Http\Controllers\Inertia\RemoveConnectedAccountsController;
use JoelButcher\Socialstream\Http\Controllers\OAuthController;

Route::group(['middleware' => config('socialstream.middleware', ['web'])], function () {
Route::get('/oauth/{provider}', [OAuthController::class, 'redirectToProvider'])->name('oauth.redirect');
Route::get('/oauth/{provider}/callback', [OAuthController::class, 'handleProviderCallback'])->name('oauth.callback');

if (config('jetstream.stack') === 'inertia') {
Route::delete('/user/connected-account/{id}', [RemoveConnectedAccountsController::class, 'destroy'])
->name('connected-accounts.destroy');

Route::put('/user/set-password', [PasswordController::class, 'store'])->name('user-password.set');
}
});
Loading

0 comments on commit e742e74

Please sign in to comment.