forked from loafle/openapi-generator-original
[Slim] Add Basic authentication middleware (#606)
* [Slim] Add Basic Authentication Middleware User needs to add own implementation to verifyCredentials method in AuthBasic.php. * [Slim] Update README template I'm not sure about `middlewareSrcPath` variable. I'll fix it in following PRs if path is broken. Hope that notice in README catches attention and most of users will read it. * Revert "[Slim] Update README template" This reverts commit204ee02fd8. * Revert "[Slim] Add Basic Authentication Middleware" This reverts commit6a8e03079a. * [Slim] Add "tuupola/slim-basic-auth" package Package "tuupola/slim-basic-auth" 3.1.0 requires PHP 7, that's why I set it's version to ^3.0.0 in Composer. Minimum version will be 3.0.0-rc.1 which supports PHP 5.5. I've tested build with PHP 7, it would be nice to check build with PHP 5.5 someday. * [Slim] Update README template Not sure about forward slash in path to SlimRouter class. I will fix it in upcoming PRs if necessary. * [Slim] Refresh samples
This commit is contained in:
committed by
William Cheng
parent
f793ac25c7
commit
58e0946b1e
@@ -34,6 +34,7 @@ use OpenAPIServer\Api\UserApi;
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
|
||||
/**
|
||||
* SlimRouter Class Doc Comment
|
||||
@@ -61,40 +62,119 @@ class SlimRouter {
|
||||
public function __construct($container = []) {
|
||||
$app = new App($container);
|
||||
|
||||
$app->PATCH('/v2/another-fake/dummy', AnotherFakeApi::class . ':testSpecialTags');
|
||||
$app->POST('/v2/fake/outer/boolean', FakeApi::class . ':fakeOuterBooleanSerialize');
|
||||
$app->POST('/v2/fake/outer/composite', FakeApi::class . ':fakeOuterCompositeSerialize');
|
||||
$app->POST('/v2/fake/outer/number', FakeApi::class . ':fakeOuterNumberSerialize');
|
||||
$app->POST('/v2/fake/outer/string', FakeApi::class . ':fakeOuterStringSerialize');
|
||||
$app->PUT('/v2/fake/body-with-file-schema', FakeApi::class . ':testBodyWithFileSchema');
|
||||
$app->PUT('/v2/fake/body-with-query-params', FakeApi::class . ':testBodyWithQueryParams');
|
||||
$app->PATCH('/v2/fake', FakeApi::class . ':testClientModel');
|
||||
$app->POST('/v2/fake', FakeApi::class . ':testEndpointParameters');
|
||||
$app->GET('/v2/fake', FakeApi::class . ':testEnumParameters');
|
||||
$app->POST('/v2/fake/inline-additionalProperties', FakeApi::class . ':testInlineAdditionalProperties');
|
||||
$app->GET('/v2/fake/jsonFormData', FakeApi::class . ':testJsonFormData');
|
||||
$app->PATCH('/v2/fake_classname_test', FakeClassnameTags123Api::class . ':testClassname');
|
||||
$app->POST('/v2/pet', PetApi::class . ':addPet');
|
||||
$app->GET('/v2/pet/findByStatus', PetApi::class . ':findPetsByStatus');
|
||||
$app->GET('/v2/pet/findByTags', PetApi::class . ':findPetsByTags');
|
||||
$app->PUT('/v2/pet', PetApi::class . ':updatePet');
|
||||
$app->DELETE('/v2/pet/{petId}', PetApi::class . ':deletePet');
|
||||
$app->GET('/v2/pet/{petId}', PetApi::class . ':getPetById');
|
||||
$app->POST('/v2/pet/{petId}', PetApi::class . ':updatePetWithForm');
|
||||
$app->POST('/v2/pet/{petId}/uploadImage', PetApi::class . ':uploadFile');
|
||||
$app->POST('/v2/fake/{petId}/uploadImageWithRequiredFile', PetApi::class . ':uploadFileWithRequiredFile');
|
||||
$app->GET('/v2/store/inventory', StoreApi::class . ':getInventory');
|
||||
$app->POST('/v2/store/order', StoreApi::class . ':placeOrder');
|
||||
$app->DELETE('/v2/store/order/{order_id}', StoreApi::class . ':deleteOrder');
|
||||
$app->GET('/v2/store/order/{order_id}', StoreApi::class . ':getOrderById');
|
||||
$app->POST('/v2/user', UserApi::class . ':createUser');
|
||||
$app->POST('/v2/user/createWithArray', UserApi::class . ':createUsersWithArrayInput');
|
||||
$app->POST('/v2/user/createWithList', UserApi::class . ':createUsersWithListInput');
|
||||
$app->GET('/v2/user/login', UserApi::class . ':loginUser');
|
||||
$app->GET('/v2/user/logout', UserApi::class . ':logoutUser');
|
||||
$app->DELETE('/v2/user/{username}', UserApi::class . ':deleteUser');
|
||||
$app->GET('/v2/user/{username}', UserApi::class . ':getUserByName');
|
||||
$app->PUT('/v2/user/{username}', UserApi::class . ':updateUser');
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
"authenticator" => function ($arguments) {
|
||||
$user = $arguments["user"];
|
||||
$password = $arguments["password"];
|
||||
return false;
|
||||
}
|
||||
]);
|
||||
|
||||
$app->PATCH(
|
||||
'/v2/another-fake/dummy', AnotherFakeApi::class . ':testSpecialTags'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/boolean', FakeApi::class . ':fakeOuterBooleanSerialize'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/composite', FakeApi::class . ':fakeOuterCompositeSerialize'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/number', FakeApi::class . ':fakeOuterNumberSerialize'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/string', FakeApi::class . ':fakeOuterStringSerialize'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/fake/body-with-file-schema', FakeApi::class . ':testBodyWithFileSchema'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/fake/body-with-query-params', FakeApi::class . ':testBodyWithQueryParams'
|
||||
);
|
||||
$app->PATCH(
|
||||
'/v2/fake', FakeApi::class . ':testClientModel'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake', FakeApi::class . ':testEndpointParameters'
|
||||
)->add(
|
||||
$basicAuth
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/fake', FakeApi::class . ':testEnumParameters'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/inline-additionalProperties', FakeApi::class . ':testInlineAdditionalProperties'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/fake/jsonFormData', FakeApi::class . ':testJsonFormData'
|
||||
);
|
||||
$app->PATCH(
|
||||
'/v2/fake_classname_test', FakeClassnameTags123Api::class . ':testClassname'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/pet', PetApi::class . ':addPet'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/pet/findByStatus', PetApi::class . ':findPetsByStatus'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/pet/findByTags', PetApi::class . ':findPetsByTags'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/pet', PetApi::class . ':updatePet'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/pet/{petId}', PetApi::class . ':deletePet'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/pet/{petId}', PetApi::class . ':getPetById'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/pet/{petId}', PetApi::class . ':updatePetWithForm'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/pet/{petId}/uploadImage', PetApi::class . ':uploadFile'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/{petId}/uploadImageWithRequiredFile', PetApi::class . ':uploadFileWithRequiredFile'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/store/inventory', StoreApi::class . ':getInventory'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/store/order', StoreApi::class . ':placeOrder'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/store/order/{order_id}', StoreApi::class . ':deleteOrder'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/store/order/{order_id}', StoreApi::class . ':getOrderById'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/user', UserApi::class . ':createUser'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/user/createWithArray', UserApi::class . ':createUsersWithArrayInput'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/user/createWithList', UserApi::class . ':createUsersWithListInput'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/user/login', UserApi::class . ':loginUser'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/user/logout', UserApi::class . ':logoutUser'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/user/{username}', UserApi::class . ':deleteUser'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/user/{username}', UserApi::class . ':getUserByName'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/user/{username}', UserApi::class . ':updateUser'
|
||||
);
|
||||
|
||||
$this->slimApp = $app;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user