Skip to content

Commit

Permalink
rename project
Browse files Browse the repository at this point in the history
  • Loading branch information
HergenD committed Jul 9, 2020
1 parent d95ab1c commit 39d3951
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

All notable changes to `jwtfusionauth` will be documented in this file.
All notable changes to `jwtauthroles` will be documented in this file.

## Version 1.0

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "werk365/jwtfusionauth",
"description": "Use JWT to auth users in Laravel",
"name": "werk365/jwtauthroles",
"description": "Use JWT to auth users and assign roles in Laravel",
"version": "1.0.0-alpha",
"license": "MIT",
"authors": [
Expand All @@ -10,8 +10,8 @@
"homepage": "https://365werk/nl"
}
],
"homepage": "https://github.com/365werk/jwtfusionauth",
"keywords": ["Laravel", "jwtfusionauth"],
"homepage": "https://github.com/365werk/jwtauthroles",
"keywords": ["Laravel", "jwtauthroles"],
"require": {
"illuminate/support": "~5|~6|~7",
"firebase/php-jwt": "^5.2",
Expand All @@ -25,21 +25,21 @@
},
"autoload": {
"psr-4": {
"werk365\\jwtfusionauth\\": "src/"
"werk365\\jwtauthroles\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"werk365\\jwtfusionauth\\Tests\\": "tests"
"werk365\\jwtauthroles\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"werk365\\jwtfusionauth\\jwtfusionauthServiceProvider"
"werk365\\jwtauthroles\\jwtauthrolesServiceProvider"
],
"aliases": {
"jwtfusionauth": "werk365\\jwtfusionauth\\Facades\\jwtfusionauth"
"jwtauthroles": "werk365\\jwtauthroles\\Facades\\jwtauthroles"
}
}
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on [Github](https://github.com/werk365/jwtfusionauth).
Contributions are accepted via Pull Requests on [Github](https://github.com/werk365/jwtauthroles).

# Things you could do
If you want to contribute but do not know where to start, this list provides some starting points.
Expand Down
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# jwtfusionauth
# jwtauthroles

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
Expand All @@ -12,13 +12,13 @@ Take a look at [contributing.md](contributing.md) to see a to do list.
Via Composer

``` bash
$ composer require werk365/jwtfusionauth
$ composer require werk365/jwtauthroles
```

Publish config and migration

```bash
$ php artisan vendor:publish --provider="werk365\jwtfusionauth\jwtfusionauthServiceProvider"
$ php artisan vendor:publish --provider="werk365\jwtauthroles\jwtauthrolesServiceProvider"
```

Run migration
Expand All @@ -35,7 +35,7 @@ public function boot()
$this->registerPolicies();

Auth::viaRequest('jwt', function ($request) {
return jwtfusionauth::authUser($request);
return jwtauthroles::authUser($request);
});
}
```
Expand Down Expand Up @@ -84,12 +84,12 @@ If you discover any security related issues, please email author email instead o

license. Please see the [license file](license.md) for more information.

[ico-version]: https://img.shields.io/packagist/v/werk365/jwtfusionauth.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/werk365/jwtfusionauth.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/werk365/jwtfusionauth/master.svg?style=flat-square
[ico-version]: https://img.shields.io/packagist/v/werk365/jwtauthroles.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/werk365/jwtauthroles.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/werk365/jwtauthroles/master.svg?style=flat-square
[ico-styleci]: https://styleci.io/repos/12345678/shield

[link-packagist]: https://packagist.org/packages/werk365/jwtfusionauth
[link-downloads]: https://packagist.org/packages/werk365/jwtfusionauth
[link-packagist]: https://packagist.org/packages/werk365/jwtauthroles
[link-downloads]: https://packagist.org/packages/werk365/jwtauthroles
[link-author]: https://github.com/HergenD
[link-contributors]: ../../contributors
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace werk365\jwtfusionauth\Facades;
namespace werk365\jwtauthroles\Facades;

use Illuminate\Support\Facades\Facade;

class jwtfusionauth extends Facade
class jwtauthroles extends Facade
{
/**
* Get the registered name of the component.
Expand All @@ -13,6 +13,6 @@ class jwtfusionauth extends Facade
*/
protected static function getFacadeAccessor()
{
return 'jwtfusionauth';
return 'jwtauthroles';
}
}
2 changes: 1 addition & 1 deletion src/Models/jwk.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace werk365\jwtfusionauth\Models;
namespace werk365\jwtauthroles\Models;

use Illuminate\Database\Eloquent\Model;

Expand Down
22 changes: 11 additions & 11 deletions src/jwtfusionauth.php → src/jwtauthroles.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace werk365\jwtfusionauth;
namespace werk365\jwtauthroles;

use werk365\jwtfusionauth\Models\jwk;
use werk365\jwtauthroles\Models\jwk;
use App\User;
use Firebase\JWT\JWT;
use phpseclib\Crypt\RSA;
use phpseclib\Math\BigInteger;
use Spatie\Permission\Models\Role;

class jwtfusionauth
class jwtauthroles
{
private static function getKid(string $jwt) {
$tks = explode('.', $jwt);
Expand Down Expand Up @@ -105,17 +105,17 @@ private static function verifyToken(string $jwt, string $uri, bool $jwk = false)
public static function authUser(object $request)
{
$jwt = $request->bearerToken();
$uri = config('jwtfusionauth.useJwk')?config('jwtfusionauth.jwkUri'):config('jwtfusionauth.pemUri');
$claims = self::verifyToken($jwt, $uri, config('jwtfusionauth.useJwk'));
if(config('jwtfusionauth.autoCreateUser')){
$user = User::firstOrNew([config('jwtfusionauth.userId') => $claims->sub]);
$user[config('jwtfusionauth.userId')] = $claims->sub;
$uri = config('jwtauthroles.useJwk')?config('jwtauthroles.jwkUri'):config('jwtauthroles.pemUri');
$claims = self::verifyToken($jwt, $uri, config('jwtauthroles.useJwk'));
if(config('jwtauthroles.autoCreateUser')){
$user = User::firstOrNew([config('jwtauthroles.userId') => $claims->sub]);
$user[config('jwtauthroles.userId')] = $claims->sub;
$user->save();
} else {
$user = User::where(config('jwtfusionauth.userId'), '=' , $claims->sub)->firstOrFail();
$user = User::where(config('jwtauthroles.userId'), '=' , $claims->sub)->firstOrFail();
}
if(config('jwtfusionauth.usePermissions')){
if(config('jwtfusionauth.autoCreateRoles')){
if(config('jwtauthroles.usePermissions')){
if(config('jwtauthroles.autoCreateRoles')){
foreach($claims->roles as $role){
$db_role = Role::where('name', $role)->first();
if(!$db_role){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace werk365\jwtfusionauth;
namespace werk365\jwtauthroles;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;

class jwtfusionauthServiceProvider extends ServiceProvider
class jwtauthrolesServiceProvider extends ServiceProvider
{
public function boot(Filesystem $filesystem)
{
Expand All @@ -22,7 +22,7 @@ public function boot(Filesystem $filesystem)

if (function_exists('config_path')) { // function not available and 'publish' not relevant in Lumen
$this->publishes([
__DIR__.'/../config/jwtfusionauth.php' => config_path('jwtfusionauth.php'),
__DIR__.'/../config/jwtauthroles.php' => config_path('jwtauthroles.php'),
], 'config');

$this->publishes([
Expand All @@ -38,11 +38,11 @@ public function boot(Filesystem $filesystem)
*/
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/jwtfusionauth.php', 'jwtfusionauth');
$this->mergeConfigFrom(__DIR__.'/../config/jwtauthroles.php', 'jwtauthroles');

// Register the service the package provides.
$this->app->singleton('jwtfusionauth', function ($app) {
return new jwtfusionauth;
$this->app->singleton('jwtauthroles', function ($app) {
return new jwtauthroles;
});
}

Expand All @@ -53,7 +53,7 @@ public function register()
*/
public function provides()
{
return ['jwtfusionauth'];
return ['jwtauthroles'];
}

/**
Expand All @@ -65,23 +65,23 @@ protected function bootForConsole()
{
// Publishing the configuration file.
$this->publishes([
__DIR__.'/../config/jwtfusionauth.php' => config_path('jwtfusionauth.php'),
], 'jwtfusionauth.config');
__DIR__.'/../config/jwtauthroles.php' => config_path('jwtauthroles.php'),
], 'jwtauthroles.config');

// Publishing the views.
/*$this->publishes([
__DIR__.'/../resources/views' => base_path('resources/views/vendor/werk365'),
], 'jwtfusionauth.views');*/
], 'jwtauthroles.views');*/

// Publishing assets.
/*$this->publishes([
__DIR__.'/../resources/assets' => public_path('vendor/werk365'),
], 'jwtfusionauth.views');*/
], 'jwtauthroles.views');*/

// Publishing the translation files.
/*$this->publishes([
__DIR__.'/../resources/lang' => resource_path('lang/vendor/werk365'),
], 'jwtfusionauth.views');*/
], 'jwtauthroles.views');*/

// Registering package commands.
// $this->commands([]);
Expand Down

0 comments on commit 39d3951

Please sign in to comment.