There is no extension able to load the - api

I integrating of bundles FOSRestBundle,JMSSerializerBundle and NelmioApiDocBundle, I modified the files config.yml and routing.yml but I find this problem
code config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#UserBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: fr
framework:
#esi: ~
translator: ~
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']
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: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
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%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: test\UserBundle\Entity\User
fos_rest:
view:
view_response_listener: 'force'
formats:
json: true
format_listener:
rules:
- { path: '^/api', priorities: ['json'], fallback_format: json, prefer_extension: true }
- { path: '^/', stop: true }
nelmio_cors:
paths:
'^/api/':
allow_credentials: true
allow_origin: ['*']
allow_headers: ['*']
allow_methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
max_age: 3600
code routing.yml:
user:
resource: "#UserBundle/Resources/config/routing.yml"
prefix: /
med:
resource: "#MedBundle/Resources/config/routing.yml"
prefix: /
app:
resource: "#AppBundle/Controller/"
type: annotation
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
NelmioApiDocBundle:
resource: "#NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /api/doc
app_api:
resource: "#MedBundle/Resources/config/routing_rest.yml"
type: rest
prefix: /api
code routing_rest.yml:
api_app:
resource: MedBundle\Controller\Api\AppController
type: rest
code AppController.php:
<?php
namespace test\MedBundle\Controller\Api;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\Controller\Annotations\RouteResource;
/**
* #RouteResource("User")
*/
Class AppController extends Controller {
public function getAction() {
$em = $this->getDoctrine()->getManager();
$test = $em->getRepository('MedBundle:Apps')->findAll();
return array("test" => $test);
}
public function postAction(Request $request){
return $request->request->all();
}
}
Now I find this problem when it can test API
What is the solution and thank you

You don't have any configuration for assetic in your config.yml file. I assume you don't have the AsseticBundle installed on your app. Since Symfony 2.8, Assetic is no longer included by default in the Symfony Standard Edition. You need to install it yourself:
First require the bundle with composer:
composer require symfony/assetic-bundle
Enable the bundle in the AppKernel.php file
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
// ...
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
);
// ...
}
}
add the following minimal configuration to your config.yml file to enable Assetic
# app/config/config.yml
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~

Related

Deploying Synapse Workspace with Managed Vnet Enabled (Bicep), but cannot assign private endpoints in UI

Situation:
I am deploying a Synapse workspace instance in Bicep with Managed Virtual Network Enabled.
I can see the Managed Vnet Is enabled from the UI:
However, when I enter the workspace my integration runtimes are not enabled for virtual network access and I cannot create managed private endpoints.
I'm writing the following code for the bicep deployment:
resource synapse_workspace 'Microsoft.Synapse/workspaces#2021-06-01' = {
name: synapse_workspace_name
location: location
tags: {
Workload: '####'
Environment: envName
Classification: 'Confidential'
Criticality: 'Low'
}
identity: {
type: 'SystemAssigned'
}
properties: {
// Git Repo
workspaceRepositoryConfiguration: {
accountName: '#####'
collaborationBranch: 'main'
projectName: '####'
repositoryName: '#############'
rootFolder: '/synapse/syn-data-${envName}'
tenantId: '####################'
type: 'WorkspaceVSTSConfiguration'
}
defaultDataLakeStorage: {
resourceId: storage_account_id
createManagedPrivateEndpoint: true
accountUrl: ###################
filesystem: ################
}
encryption: {
cmk: {
kekIdentity: {
useSystemAssignedIdentity: true
}
key: {
name: 'default'
keyVaultUrl: '#########################'
}
}
}
managedVirtualNetwork: 'default'
connectivityEndpoints: {
web: 'https://web.azuresynapse.net?workspace=%2fsubscriptions%######################
dev: 'https://##############.dev.azuresynapse.net'
sqlOnDemand: '################-ondemand.sql.azuresynapse.net'
sql: '################.sql.azuresynapse.net'
}
managedResourceGroupName: guid('synapseworkspace-managed-resource-group-${envName}')
sqlAdministratorLogin: 'sqladminuser'
privateEndpointConnections: []
managedVirtualNetworkSettings: {
preventDataExfiltration: true
allowedAadTenantIdsForLinking: []
}
publicNetworkAccess: 'Disabled'
cspWorkspaceAdminProperties: {
initialWorkspaceAdminObjectId: '#########################'
}
trustedServiceBypassEnabled: false
}
}
I get no errors in the deployment regarding the virtual network or any associated settings, but I still get the default integration runtime set to "Public" and not "Managed Virtual Network".
Is this a limitation in Bicep or am I missing some parameter?
Any help would be great
Joao

Istio configuration for websites with static content (in particular kubevious UI)

I'm trying to configure istio VirtualService so that I can open the kubevious dashboard (https://github.com/kubevious/kubevious) through it.
I have the following setup:
resource "kubernetes_manifest" "kubevious" {
provider = kubernetes-alpha
manifest = {
apiVersion = "networking.istio.io/v1alpha3"
kind = "VirtualService"
metadata = {
name = "kubevious"
namespace = "kubevious"
}
spec = {
gateways = [
"istio-system/space-gateway"
]
hosts = [
"*"
]
http = [
{
match = [
{
uri = {
prefix = "/kubevious"
}
}
]
rewrite = {
uri = "/"
}
route = [
{
destination = {
host = "kubevious-ui-svc.kubevious.svc.cluster.local"
}
}
]
},
{
match = [
{
uri = {
prefix = "/static"
}
},
{
uri = {
prefix = "/socket"
}
},
{
uri = {
regex: "^.*\\.(ico|png|jpg)$"
}
}
]
route = [
{
destination = {
host = "kubevious-ui-svc.kubevious.svc.cluster.local"
}
}
]
}
]
}
}
}
kubevious website is opening (albeit with some socket errors which I guess are related to kubevious).
I have one issue with this approach. What if I want to host more websites which have static content? Currently everything that goes to %istio_ingress_ip%/static will be forwarded to kubevious. Any other way to configure it so that i.e. when I invoke %istio_ingress_ip%/kubevious, it will resolve the static content to %istio_ingress_ip%/kubevious/static?
What if I want to host more websites which have static content?
AFAIK you should specify hosts for that, instead of *
For example let's say you have 2 static sites, example.com and sample.com, then you create 2 hosts in your virtual service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: example-vs
spec:
hosts:
- example.com <----
http:
- match:
- uri:
prefix: /example
- uri:
prefix: /static
- uri:
prefix: /socket
- uri:
regex: "^.*\\.(ico|png|jpg)$"
route:
- destination:
host: example.default.svc.cluster.local
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: sample-vs
spec:
hosts:
- sample.com <----
http:
- match:
- uri:
prefix: /sample
- uri:
prefix: /static
- uri:
prefix: /socket
- uri:
regex: "^.*\\.(ico|png|jpg)$"
route:
- destination:
host: sample.default.svc.cluster.local
Additional resources:
https://medium.com/#MATT.LAW/istio-and-the-path-to-production-cdb260d58c85
Any other way to configure it so that i.e. when I invoke %istio_ingress_ip%/kubevious, it will resolve the static content to %istio_ingress_ip%/kubevious/static?
There are few resources worth to check about rewrite in istio.
istio: VirtualService rewrite to the root url
https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRewrite
https://discuss.istio.io/t/rewrite-url-to-the-root-in-the-gateway/2860/3

Codeception seeInDatabase() not working as expected

I have problems getting codeceptions seeInDatabase() to work. This is my Cest:
public function testContactMailCheckbox(AcceptanceTester $I) {
$I->scrollTo("#adminMailSettingsForm", 0, -200);
$I->seeInDatabase("pib_users", [
"user_email" => "admin-cest#example.org",
"user_receive_contact_notification" => 0
]);
$I->click("//label[#for='contactMailNotification']", "#adminMailSettingsForm");
$I->waitForJS("return $.active == 0;",10);
$I->wait(100);
$I->seeInDatabase("pib_users", [
"user_email" => "admin-cest#example.org",
"user_receive_contact_notification" => 1
]);
}
The first seeInDatabase() passes, everything is fine. I can verify that this seeInDatabase-Assertion works correctly, by changing the default-data in my database dump. When I change the default data to "user_receive_contact_notification" => 1, the first seeInDatabase fails, which means it is working correctly.
I use $I->wait(100) to verify, that there are no synchronisation-issues. During this timespan I can check via phpMyAdmin, that the row was indeed updated correctly. That means the test should pass.
Here is my Db-config:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://pib.local/'
window_size: false # disabled in ChromeDriver
port: 5555
browser: chrome
capabilities:
chromeOptions:
args: ["--headless", "--no-sandbox", "--disable-gpu", "--window-size=1920,1080"]
- \Helper\Acceptance
- Sequence
- \Helper\DbHelper
config:
\Helper\DbHelper:
user: "root"
password: ""
dsn: "mysql:host=localhost;dbname=pib"
cleanup: true
dump: 'tests/database_dump_tests.sql'
populate: true
reconnect: true
step_decorators: ~
My DbHelper contains only a single function:
class DbHelper extends \Codeception\Module\Db
{
public function putInDatabase($table, $data, $insertOnlyIfNotExisting = true) {
// if ignoreDuplicateError is true, only execute insert when not existing already
if($this->countInDatabase($table, $data) == 0 | !$insertOnlyIfNotExisting) {
$this->_insertInDatabase($table, $data);
}
}
}
This might be related to this question. I don't use Laravel though, so just using the seeRecord()-helper isn't going to help me.

hapi-sequelize 3.0.4 support for Hapi version 17.2.0

I am trying to use hapi-sequelize 3.0.4 with hapi.js 17.2.0 using the following configuration:
{
plugin: require("hapi-sequelize"),
options:[
{
name: "mysql", // identifier
models: ["./plugins/sequelize/models/*.js"], // paths/globs to model files
sequelize: new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASS,
{
host: process.env.DB_HOST,
dialect: "mysql",
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 3306
}
), // sequelize instance
sync: false, // sync models - default false
forceSync: false // force sync (drops tables) - default false
}
]
}
It gives the following error:
name[1] --missing---
Is this the latest version of hapi-sequelize compatible with hapi.js 17.2.0?

Authentication with a second manager

I created a second manager for my second database.
In this base, i create a table which it contains my users.
The problem is the symfony don't load users from this database.
here is an extract of my config.yml :
Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
seconddb:
driver: pdo_mysql
host: "xx.xx.xx.xx"
port: "3306"
dbname: "acme_test"
user: "acmegamestest"
password: "mypassword"
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:
default_entity_manager: default
auto_generate_proxy_classes: "%kernel.debug%"
#naming_strategy: doctrine.orm.naming_strategy.underscore
entity_managers:
default:
connection: default
mappings:
acmeAdminBundle: ~
acmeBlogBundle: ~
gedmo_translatable:
type: annotation
alias: GedmoTranslatable
prefix: Gedmo\Translatable\Entity
is_bundle: false
# make sure vendor library location is correct
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
seconddb:
connection: seconddb
mappings:
acmeJoueurBundle: ~
and here is an extract of my security.yml :
encoders:
FOS\UserBundle\Model\UserInterface: sha512
Acme\JoueurBundle\Entity\Players:
algorithm: sha512
encode_as_base64: false
providers:
seconddb:
entity:
class: Acme\JoueurBundle\Entity\Players
property: username
manager_name: seconddb
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
administration:
pattern: ^/admin
provider: fos_userbundle
context: administration
form_login:
#csrf_provider: security.csrf.token_manager
login_path : fos_user_security_login
check_path : fos_user_security_check
failure_path : null
default_target_path : /admin
logout:
path : fos_user_security_logout
target : /connexion
anonymous: true
frontend:
pattern: ^/
provider: acme_joueurbundle
context: frontend
form_login:
#csrf_provider: form.csrf_provider
login_path : acme_players_login
check_path : acme_players_check
failure_path : null
default_target_path : acme_players_userprofile
logout:
path : acme_players_logout
target : acme_players_login
anonymous: true
and my entity implements "AdvancedUserInterface, \Serializable"
with this function :
//////////////////////////liaison pour symfony////////////////////////////
public function getRoles()
{
return array('ROLE_PLAYERS');
}
public function getSalt(){
return $this->salt;
}
public function eraseCredentials(){
}
public function isAccountNonExpired()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return !$this->banned;
}
public function isEnabled()
{
return $this->active;
}
/** #see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
$this->active
// see section on salt below
// $this->salt,
));
}
/** #see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
$this->active
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
/////////////////////////////////////////////////////////////////////////////
However when i trying to connect, i get this errors in dump function :
and in the section Doctrine i get this :
Is what you know the solution?
Hope you can help me.
Thanks
EDIT
So, the error comes from this piece of code in the user authentication provider :
try {
$user = $this->retrieveUser($username, $token);
} catch (UsernameNotFoundException $e) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials.', 0, $e);
}
$e->setUsername($username);
throw $e;
}
The method retrieveUser failed and it throws bad crendentials exception. This explains why there is no connection since it has not yet been called.
Before asking you for the code of your provider, let's look at your security.yml because you create a provider called seconddb and in your firewall frontend you try to call a provider acme_joueurbundle who propably doesn't exist.
So, your security.yml should look like this:
# app/config/security.yml
[...]
providers:
seconddb:
entity:
class: Acme\JoueurBundle\Entity\Players
property: username
manager_name: seconddb
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
administration:
provider: fos_userbundle
[...]
frontend:
provider: seconddb
[...]