Skip to content

Instantly share code, notes, and snippets.

@3kynox
Created January 6, 2016 12:52
Show Gist options
  • Save 3kynox/3c7b4930c1d619fa2a6d to your computer and use it in GitHub Desktop.
Save 3kynox/3c7b4930c1d619fa2a6d to your computer and use it in GitHub Desktop.

Revisions

  1. 3kynox created this gist Jan 6, 2016.
    98 changes: 98 additions & 0 deletions config.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }

    framework:
    #esi: ~
    #translator: { fallbacks: ["%locale%"] }
    secret: "%secret%"
    router:
    resource: "%kernel.root_dir%/config/routing.yml"
    strict_requirements: ~
    form: ~
    csrf_protection: ~
    validation: { enable_annotations: true }
    serializer: { enable_annotations: true }
    templating:
    engines: ['twig']
    #assets_version: SomeVersionScheme
    default_locale: "%locale%"
    trusted_hosts: ~
    trusted_proxies: ~
    session:
    # handler_id set to null will use default session handler from php.ini
    handler_id: ~
    fragments: ~
    http_method_override: false

    # Twig Configuration
    twig:
    debug: "%kernel.debug%"
    strict_variables: "%kernel.debug%"

    # Doctrine Configuration
    doctrine:
    dbal:
    driver: "%database_driver%"
    host: "%database_host%"
    port: "%database_port%"
    dbname: "%database_name%"
    user: "%database_user%"
    password: "%database_password%"
    charset: UTF8
    # if using pdo_sqlite as your database driver:
    # 1. add the path in parameters.yml
    # e.g. database_path: "%kernel.root_dir%/data/data.db3"
    # 2. Uncomment database_path in parameters.yml.dist
    # 3. Uncomment next line:
    # path: "%database_path%"

    orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true

    # Swiftmailer Configuration
    swiftmailer:
    transport: "%mailer_transport%"
    host: "%mailer_host%"
    username: "%mailer_user%"
    password: "%mailer_password%"
    spool: { type: memory }

    # DunglasJsonLdApi configuration
    dunglas_api:
    title: "%api_name%"
    description: "%api_description%"

    # Nelmio CORS
    nelmio_cors:
    defaults:
    allow_origin: ["%cors_allow_origin%"]
    allow_methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS"]
    allow_headers: ["content-type", "authorization"]
    max_age: 3600
    paths:
    '^/': ~

    # Nelmio API Doc
    nelmio_api_doc:
    sandbox:
    accept_type: "application/json"
    body_format:
    formats: [ "json" ]
    default_format: "json"
    request_format:
    formats:
    json: "application/json"

    fos_user:
    db_driver: orm
    firewall_name: main
    user_class: AppBundle\Entity\User

    lexik_jwt_authentication:
    private_key_path: %jwt_private_key_path%
    public_key_path: %jwt_public_key_path%
    pass_phrase: %jwt_key_pass_phrase%
    token_ttl: %jwt_token_ttl%
    14 changes: 14 additions & 0 deletions routing.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    api:
    resource: "."
    type: "api"
    prefix: "/api"

    NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix: "/doc"

    fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

    api_login_check:
    path: /login_check
    49 changes: 49 additions & 0 deletions security.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    security:
    encoders:
    FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
    ROLE_ADMIN: ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
    fos_userbundle:
    id: fos_user.user_provider.username

    firewalls:
    dev:
    pattern: ^/(_(profiler|wdt)|css|images|js)/
    security: false
    main:
    pattern: ^/
    provider: fos_userbundle
    stateless: true
    form_login:
    # csrf_token_generator: security.csrf.token_manager
    check_path: /login_check
    username_parameter: _username
    password_parameter: _password
    success_handler: lexik_jwt_authentication.handler.authentication_success
    failure_handler: lexik_jwt_authentication.handler.authentication_failure
    require_previous_session: false
    logout: true
    anonymous: true
    api:
    pattern: ^/api
    stateless: true
    lexik_jwt:
    authorization_header:
    enabled: true
    prefix: Bearer
    query_parameter:
    enabled: true
    name: Bearer
    throw_exceptions: false
    create_entry_point: true
    authentication_provider: lexik_jwt_authentication.security.authentication.provider

    access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api, roles: [IS_AUTHENTICATED_FULLY]}