...
 
Commits (27)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>
# This file is a "template" of what your parameters.yml file should look like
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: ~
mailer_password: ~
locale: en
# A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt
......@@ -16,60 +16,28 @@ security:
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
# in_memory:
# memory:
# users:
# user: { password: $2a$12$Epmi2uGZ8sdk6H.TmgPBdOZzgGk7/i5tsr8j4dWAdEkLcM.n.f3QW, roles: [ 'ROLE_USER' ] }
# admin: { password: $2a$12$oKHYGNTsa7/MSFD1GhpX2uaL0VUG7HFw0sVsJN.oJr.TvSU2qSXTu, roles: [ 'ROLE_ADMIN' ] }
our_db_provider:
entity:
class: ApiBundle:PsCustomer
# property: pseudo
# if you're using multiple entity managers
# manager_name: customer
# the main part of the security, where you can set up firewalls
# for specific sections of your app
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
# the login page has to be accessible for everybody
demo_login:
pattern: ^/demo/secured/login$
security: false
# secures part of the application
demo_secured_area:
pattern: ^/demo/secured/
# it's important to notice that in this case _demo_security_check and _demo_login
# are route names and that they are specified in the AcmeDemoBundle
form_login:
check_path: _demo_security_check
login_path: _demo_login
logout:
path: _demo_logout
target: _demo
#anonymous: ~
#http_basic:
# realm: "Secured Demo Area"
# api
main:
pattern: ^/login.html$
anonymous: true
http_basic: ~
#provider: our_db_provider
create_user:
pattern: ^/pscustomer$
create_customer:
pattern: ^/pscustomer/create$
anonymous: true
http_basic: ~
secured:
pattern: ^/
entry_point : api.authenticationentrypoint
form_login:
require_previous_session: false
success_handler: api.authenticationsuccess.handler
failure_handler: api.authenticationfailure.handler
login_path: login_route
......@@ -77,6 +45,7 @@ security:
logout:
path: logout
target: login_route
success_handler: api.logoutsuccess.handler
# with these settings you can restrict or allow access for different parts
# of your application based on roles, ip, host or methods
......
<?php
namespace ApiBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Util\Codes;
use FOS\RestBundle\Controller\Annotations;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\Controller\Annotations\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\FormTypeInterface;
use ApiBundle\Form\PsAccessType;
use ApiBundle\Entity\CommonInterface;
class PsAccessRestController extends FOSRestController
{
/**
* List all PsAccesss.
*
*
* @Route(requirements={"_format"="json"}, defaults={"_format" = "json"})
* @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing ppsaccesss.")
* @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many ppsaccesss to return.")
*
* @param Request $request the request object
* @param ParamFetcherInterface $paramFetcher param fetcher service
*
* @return array
*/
public function getAllAction(Request $request, ParamFetcherInterface $paramFetcher)
{
$offset = $paramFetcher->get('offset');
$offset = null == $offset ? 0 : $offset;
$limit = $paramFetcher->get('limit');
return $this->container->get('api.psaccess.handler')->all($limit, $offset);
}
/**
* Get single psaccess.
*
* @param int $id the psaccess id
*
* @Route(requirements={"_format"="json", "id": "\d+"}, defaults={"_format" = "json"})
* @return array
*
* @throws NotFoundHttpException when ppsaccess not exist
*/
public function getAction($id)
{
$ppsaccess = $this->getOr404($id);
return $ppsaccess;
}
/**
* Presents the form to use to create a new psaccess.
*
* @Annotations\View(
* templateVar = "form"
* )
* @Route(requirements={"_format"="html"}, defaults={"_format" = "html"})
* @return FormTypeInterface
*/
public function newAction()
{
return $this->createForm(new PsAccessType());
}
/**
* Create an psaccess from the submitted data.
*
*
* @Annotations\View(
* template = "ApiBundle::newPsAccess.html.twig",
* statusCode = Codes::HTTP_BAD_REQUEST,
* templateVar = "form"
* )
* @Route(requirements={"_format"="json"}, defaults={"_format" = "json"})
*
* @param Request $request the request object
*
* @return FormTypeInterface|View
*/
public function postAction(Request $request)
{
try {
$new = $this->container->get('api.psaccess.handler')->post(
$request->request->all()
);
$routeOptions = array(
'id' => $new->getId(),
'_format' => $request->get('_format')
);
return $this->routeRedirectView('api_psaccess_get', $routeOptions, Codes::HTTP_CREATED);
} catch (InvalidFormException $exception) {
return $exception->getForm();
}
}
/**
* Update existing psaccess from the submitted data or create a new psaccess at a specific location.
*
*
* @Annotations\View(
* template = "ApiBundle::editPsAccess.html.twig",
* templateVar = "form"
* )
* @Route(requirements={"id": "\d+"})
*
* @param Request $request the request object
* @param int $id the psaccess id
*
* @return FormTypeInterface|View
*
* @throws NotFoundHttpException when psaccess not exist
*/
public function putAction(Request $request, $id)
{
try {
if (!($ppsaccess = $this->container->get('api.psaccess.handler')->get($id))) {
$statusCode = Codes::HTTP_CREATED;
$ppsaccess = $this->container->get('api.psaccess.handler')->post(
$request->request->all()
);
} else {
$statusCode = Codes::HTTP_NO_CONTENT;
$ppsaccess = $this->container->get('api.psaccess.handler')->put(
$ppsaccess,
$request->request->all()
);
}
$routeOptions = array(
'id' => $ppsaccess->getId(),
'_format' => $request->get('_format')
);
return $this->routeRedirectView('api_psaccess_get', $routeOptions, $statusCode);
} catch (InvalidFormException $exception) {
return $exception->getForm();
}
}
/**
* Update existing psaccess from the submitted data or create a new psaccess at a specific location.
*
*
* @Annotations\View(
* template = "ApiBundle::editPsAccess.html.twig",
* templateVar = "form"
* )
* @Route(requirements={"id": "\d+"})
*
* @param Request $request the request object
* @param int $id the psaccess id
*
* @return FormTypeInterface|View
*
* @throws NotFoundHttpException when ppsaccess not exist
*/
public function patchAction(Request $request, $id)
{
try {
$ppsaccess = $this->container->get('api.psaccess.handler')->patch(
$this->getOr404($id),
$request->request->all()
);
$routeOptions = array(
'id' => $ppsaccess->getId(),
'_format' => $request->get('_format')
);
return $this->routeRedirectView('api_psaccess_get', $routeOptions, Codes::HTTP_NO_CONTENT);
} catch (InvalidFormException $exception) {
return $exception->getForm();
}
}
/**
* Fetch a PsAccess or throw an 404 Exception.
*
* @param mixed $id
*
* @return PsAccessInterface
*
* @throws NotFoundHttpException
*/
protected function getOr404($id)
{
if (!($psaccess = $this->container->get('api.psaccess.handler')->get($id))) {
throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$id));
}
return $psaccess;
}
}
?>
<?php
namespace ApiBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Util\Codes;
use FOS\RestBundle\Controller\Annotations;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\Controller\Annotations\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\FormTypeInterface;
use ApiBundle\Form\PsAddressFormatType;
use ApiBundle\Entity\CommonInterface;
class PsAddressFormatRestController extends FOSRestController
{
/**
* List all PsAddressFormats.
*
*
* @Route(requirements={"_format"="json"}, defaults={"_format" = "json"})
* @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing ppsaddressformats.")
* @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many ppsaddressformats to return.")
*
* @param Request $request the request object
* @param ParamFetcherInterface $paramFetcher param fetcher service
*
* @return array
*/
public function getAllAction(Request $request, ParamFetcherInterface $paramFetcher)
{
$offset = $paramFetcher->get('offset');
$offset = null == $offset ? 0 : $offset;
$limit = $paramFetcher->get('limit');
return $this->container->get('api.psaddressformat.handler')->all($limit, $offset);
}
/**
* Get single psaddressformat.
*
* @param int $id the psaddressformat id
*
* @Route(requirements={"_format"="json", "id": "\d+"}, defaults={"_format" = "json"})
* @return array
*
* @throws NotFoundHttpException when ppsaddressformat not exist
*/
public function getAction($id)
{
$ppsaddressformat = $this->getOr404($id);
return $ppsaddressformat;
}
/**
* Presents the form to use to create a new psaddressformat.
*
* @Annotations\View(
* templateVar = "form"
* )
* @Route(requirements={"_format"="html"}, defaults={"_format" = "html"})
* @return FormTypeInterface
*/
public function newAction()
{
return $this->createForm(new PsAddressFormatType());
}
/**
* Create an psaddressformat from the submitted data.
*
*
* @Annotations\View(
* template = "ApiBundle::newPsAddressFormat.html.twig",
* statusCode = Codes::HTTP_BAD_REQUEST,
* templateVar = "form"
* )
* @Route(requirements={"_format"="json"}, defaults={"_format" = "json"})
*
* @param Request $request the request object
*
* @return FormTypeInterface|View
*/
public function postAction(Request $request)
{
try {
$new = $this->container->get('api.psaddressformat.handler')->post(