Here is my application.yml
dataSources:
dataSource:
loggingSql: true
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
environments:
development:
dataSources:
dataSource:
dbCreate: validate
url: jdbc:oracle:thin:#hostname:1521/mydb driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
jndiName: java:comp/env/jdbc/devapp
grails.naming.entries:
jdbc:
devapp:
type: javax.sql.DataSource
driverClassName: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:#hostname:1521/mydb
username: "username"
password: "password"
properties:
maxActive: 20
maxIdle: 4
initialSize: 4
maxWait: -1
And here is my build.gradle entries:
runtime "oracle:ojdbc6:11.2.0.4.0"
Build fails with the following error.
Error Could not resolve all dependencies for configuration ':testRuntime'. Type 'gradle dependencies' for more information
When I placed the following dependency in build.gradle, it worked.
compile 'com.oracle:ojdbc6:11.2.0.3'
Related
After reading the documentation, I've encountered a problem, I'm getting the error unable to connect to the database. I'm trying to connect to a local SQL Server database, using NestJS. I enabled a user sa and set its password. I also enabled TCP/IP connection and confirmed the port from SQL Server. I'm wondering what am I missing or doing wrong?
#Module({
imports: [
ConfigModule.forRoot({
envFilePath:'.env',
isGlobal: true
}),
TypeOrmModule.forRoot({
type: 'mssql',
host: 'localhost',
port: 1433,
username: 'root',
password: 'root',
database: 'test',
autoLoadEntities: true,
synchronize: true,
}),
],
controllers: [AppController, EstadoProyController],
providers: [AppService],
})
export class AppModule {}
check this items:
1- sql server running
2- check your port or host
I have a Spring Boot application.
And my Liquibase doesn't create the DATABASECHANGELOG table.
It proceeds the changelog and after that throws an error.
Any ideas what could be wrong?
Something is missing?
error:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'addressbook.DATABASECHANGELOG' doesn't exist
config:
spring:
jpa:
show-sql: false
hibernate:
ddl-auto: none
datasource:
url: jdbc:mysql://localhost:3306/addressbook?characterEncoding=UTF-8
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
liquibase:
enabled: true
change-log: "classpath:db/liquibase-changelog.yml"
changelog:
databaseChangeLog:
- changeSet:
id: 1
author: me
changes:
- sqlFile:
path: sql/20181025_startup.sql
relativeToChangelogFile: true
stripComments: true
- changeSet:
id: 2
author: me
changes:
- sqlFile:
path: sql/20181026_create_table_contacts.sql
relativeToChangelogFile: true
stripComments: true
dependencies:
gradleVersion=4.10.2
springCloudVersion=Finchley.SR2
springBootVersion=2.0.6.RELEASE
mysqlVersion=5.1.47
liquibaseVersion=3.6.2
Error from cmd
I used the same id and password to connect to the same database using MS SQL Server management studio, but when I connect in typeorm, the error pops out as shown in the attachment.
the following is my script to connect the database
import "reflect-metadata";
import { createConnection } from "typeorm";
createConnection({
type: "mssql",
host: "localhost",
port: 3000,
username: "root",
password: "12345",
database: "ABC",
entities: [
],
extra: {
options: {
encrypt: false
},
},
synchronize: true,
logging: false
}).then(connection => {
// here you can start to work with your entities
}).catch(error => console.log(error));
anyone have any idea on how to solve this?
looks like the port number provided is wrong. Please correct your port number. The default port number for MSSQL is 1433
I am using LexikJWTBundle to authenticate an ionic angularjs app to a symfony2REST API.
My issue is that when I try to authenticate the user, Symfony returns : no route found for POST /api/login_check.
EDIT
I had put the route in my rest routing file so the resulting route was /api/api/login_check.
Now the error is: Unable to find the controller for path "/api/login_check".
It looks like LexikJWTBundle doesn't intercept the call.
End EDIT
I precise that my api is working fine w/o authentication and uses CORS though NelmioCorsBundle.
Here is my routing.yml portion:
api_login_check:
path: /api/login_check
Here is my config.yml
lexik_jwt_authentication:
private_key_path: %kernel.root_dir%/var/jwt/private.pem # ssh private key path
public_key_path: %kernel.root_dir%/var/jwt/public.pem # ssh public key path
pass_phrase: 'passphrase' # ssh key pass phrase
token_ttl: 86400 # token ttl - defaults to 86400
Here is my security.yml:
# app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/{_{profiler|wdt}}/
security: false
switch_user: true
main:
pattern: .*
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
switch_user: true
# JWT SETUP
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
check_path: /api/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
# JWT SETUP
api:
pattern: ^/api
stateless: true
lexik_jwt:
authorization_header:
enabled: true
prefix: Bearer
query_parameter:
enabled: true
name: bearer
access_control:
# JWT SETUP
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
Ok I found the issue: the firewall main should be located at the end because all routes maches this pattern and therefore prevent from going through other firewalls.
Stupid mistake again !
Thank you #keyboardSmaher for your help.
Now the security.yml looks like this:
# app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/{_{profiler|wdt}}/
security: false
switch_user: true
api_login:
pattern: ^/api/login
stateless: true
anonymous: true
provider: fos_userbundle
form_login:
check_path: api_login_check
require_previous_session: false
username_parameter: username
password_parameter: password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
api:
pattern: ^/api
stateless: true
provider: fos_userbundle
lexik_jwt: ~
main:
pattern: .*
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
switch_user: true
# JWT SETUP
# JWT SETUP
role_hierarchy:
ROLE_DELEGATION: [ROLE_USER]
ROLE_EXPORT: [ROLE_USER]
ROLE_USER_ADMIN: [ROLE_USER]
ROLE_LIST_ADMIN: [ROLE_USER]
ROLE_IMPORT: [ROLE_USER]
ROLE_MOBILE: [ROLE_USER]
ROLE_ADMIN: [ROLE_USER, ROLE_ALLOWED_TO_SWITCH]
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ALLOWED_TO_SWITCH]
access_control:
- { path: ^/$, role: ROLE_USER}
# - { path: ^/api, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/contacts, role: ROLE_USER }
- { path: ^/profile, roles: ROLE_USER }
- { path: ^/entites, role: ROLE_USER }
- { path: ^/export, role: ROLE_EXPORT }
- { path: ^/titres, roles: ROLE_ADMIN }
- { path: ^/categories, roles: ROLE_ADMIN }
- { path: ^/services, roles: ROLE_ADMIN }
- { path: ^/groupes, roles: ROLE_ADMIN }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/imports, roles: ROLE_IMPORT }
- { path: ^/utilisateurs, roles: ROLE_USER_ADMIN }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/group, roles: ROLE_USER_ADMIN }
# JWT SETUP
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
For form log in to work, you need to create the check_path route. The route has to point to an empty controller and it is intercepted by the security system.
Just create an empty controller for /api/login_check and point your api_login_check route to it.
This information is in the documentation below.
Documentation
I am building an app with angularjs frontend and symfony backend with the help of FOSOAuthServerBundle and FOSUserBundles for security.
Registration works fine but logging back in has an issue. When you provide your username/ password, authentication works fine and a token is generated but then a login form is presented to the user again to log in when they try to access a resource using the token.
I know it's a misconfiguration somewhere hoping someone will have the eye to point it our for me ;-)
security.yml
security:
encoders:
AppBundle\Entity\User:
algorithm: sha1
encode_as_base64: false
iterations: 1
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
oauth_token:
pattern: ^/oauth/v2/token
security: false
oauth_authorize:
pattern: ^/oauth/v2/auth
form_login:
provider: fos_userbundle
check_path: _security_check
login_path: _demo_login
anonymous: true
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
api:
pattern: ^/api
fos_oauth: true
stateless: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] }
config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
fos_oauth_server:
db_driver: orm
client_class: AppBundle\Entity\Client
access_token_class: AppBundle\Entity\AccessToken
refresh_token_class: AppBundle\Entity\RefreshToken
auth_code_class: AppBundle\Entity\AuthCode
service:
user_provider: fos_user.user_manager
options:
supported_scopes: user