-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from Kovah/dev
v1.1.0
- Loading branch information
Showing
140 changed files
with
775 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
name: Build simple LinkAce Docker image | ||
|
||
#on: | ||
# push: | ||
# branches: | ||
# - master | ||
# tags: | ||
# - "*" | ||
on: workflow_dispatch | ||
|
||
jobs: | ||
publish_to_docker_hub: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare tags | ||
id: prep | ||
run: | | ||
DOCKER_IMAGE=linkace/linkace | ||
VERSION=noop | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
elif [[ $GITHUB_REF == refs/heads/master ]]; then | ||
VERSION=php-nginx | ||
fi | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | ||
MINOR=${VERSION%.*} | ||
MAJOR=${MINOR%.*} | ||
TAGS="$TAGS-php-nginx,${DOCKER_IMAGE}:php-nginx" | ||
fi | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=tags::${TAGS} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
- name: Build and push simple image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./resources/docker/dockerfiles/release-simple.Dockerfile | ||
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 | ||
push: true | ||
tags: ${{ steps.prep.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
name: Build regular LinkAce Docker image | ||
|
||
#on: | ||
# push: | ||
# branches: | ||
# - master | ||
# tags: | ||
# - "*" | ||
on: workflow_dispatch | ||
|
||
jobs: | ||
publish_to_docker_hub: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare tags | ||
id: prep | ||
run: | | ||
DOCKER_IMAGE=linkace/linkace | ||
VERSION=noop | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
elif [[ $GITHUB_REF == refs/heads/master ]]; then | ||
VERSION=latest | ||
fi | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | ||
TAGS="$TAGS,${DOCKER_IMAGE}:latest" | ||
fi | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=tags::${TAGS} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
- name: Build and push advanced image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./resources/docker/dockerfiles/release.Dockerfile | ||
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 | ||
push: true | ||
tags: ${{ steps.prep.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Build Release Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
|
||
build-js: | ||
runs-on: ubuntu-latest | ||
|
||
name: Build assets for the package | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js 14.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '14.x' | ||
|
||
- name: Try to build the assets | ||
run: | | ||
npm ci | ||
npm run production | ||
- name: Upload built assets | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: assets | ||
path: public/assets/dist | ||
|
||
- name: Upload mix manifest | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: mix-manifest | ||
path: public/mix-manifest.json | ||
|
||
build-package: | ||
runs-on: ubuntu-latest | ||
needs: build-js | ||
|
||
name: Build final dist package | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: assets | ||
path: public/assets/dist | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: mix-manifest | ||
path: public | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.3' | ||
extensions: mbstring | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Prepare the environment | ||
run: cp .env.example .env | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Publish package configuration | ||
run: 'php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"' | ||
|
||
- name: Remove .env file | ||
run: rm .env | ||
|
||
- name: Build the final package | ||
uses: thedoctor0/zip-release@master | ||
with: | ||
filename: linkace.zip | ||
exclusions: '*.git*' | ||
|
||
- name: Upload the package | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: linkace-package | ||
path: linkace.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User; | ||
|
||
trait AsksForUser | ||
{ | ||
/** @var User */ | ||
protected $user; | ||
|
||
protected function askForUserEmail(): void | ||
{ | ||
do { | ||
$email = $this->ask('Please enter the user email address'); | ||
|
||
$this->user = User::where('email', $email)->first(); | ||
|
||
if (empty($this->user)) { | ||
$this->warn('A user with this email address could not be found!'); | ||
} | ||
} while (empty($this->user)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Validator; | ||
|
||
/** | ||
* Class ViewRecoveryCodesCommand | ||
* | ||
* @package App\Console\Commands | ||
*/ | ||
class ViewRecoveryCodesCommand extends Command | ||
{ | ||
use AsksForUser; | ||
|
||
protected $signature = '2fa:view-recovery-codes'; | ||
|
||
public function handle(): void | ||
{ | ||
$this->line('This tool allows you to view the 2FA recovery codes for any user.'); | ||
|
||
$this->askForUserEmail(); | ||
$this->viewBackupCodes(); | ||
} | ||
|
||
protected function viewBackupCodes(): void | ||
{ | ||
if (empty($this->user->two_factor_recovery_codes)) { | ||
$this->warn('Two Factor Authentication is not enabled for this user.'); | ||
return; | ||
} | ||
|
||
$this->info('Recovery Codes for user ' . $this->user->name .':'); | ||
|
||
$recoveryCodes = json_decode(decrypt($this->user->two_factor_recovery_codes), true); | ||
foreach ($recoveryCodes as $code) { | ||
$this->line($code); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.