Shardingsphere: authentication.password in server.yaml is not working

Created on 4 Jul 2019  ·  8Comments  ·  Source: apache/shardingsphere

Bug Report

Which version of ShardingSphere did you use?

4.0.0-RC1

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-proxy with docker 4.0.0-RC1

Expected behavior

Login Sharding-provey with preset password

Actual behavior

Password is not working, except for blank password

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Modify server.xml, restart Sharding-proxy

Example codes for reproduce this issue (such as a github link).

authentication:
  username: root
  password: root
invalid

Most helpful comment

Hi @terrymanu @tristaZero , any update?
The problem still exists, this issue should not be closed.

All 8 comments

Wrong configuration, please refer to

authentication:
  users:
    root: # username
      password: root # password
    sharding:
      password: sharding 
      authorizedSchemas: sharding_db

Different in new configuration and Doc, where can I see the relevant documentation?

And I use your configuration, then get error in log:

Exception in thread "main" Cannot create property=authentication for JavaBean=org.apache.shardingsphere.shardingproxy.config.yaml.YamlProxyServerConfiguration@3551e0c4
 in 'reader', line 1, column 1:
    authentication:
    ^
Cannot create property=users for JavaBean=org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication@74ee003d
 in 'reader', line 2, column 3:
      users:
      ^
Unable to find property 'users' on class: org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication
 in 'reader', line 3, column 5:
        root: # username
        ^

 in 'reader', line 2, column 3:
      users:
      ^

    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:312)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:345)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:141)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:127)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450)
    at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:410)
    at org.apache.shardingsphere.core.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:59)
    at org.apache.shardingsphere.shardingproxy.config.ShardingConfigurationLoader.loadServerConfiguration(ShardingConfigurationLoader.java:77)
    at org.apache.shardingsphere.shardingproxy.config.ShardingConfigurationLoader.load(ShardingConfigurationLoader.java:58)
    at org.apache.shardingsphere.shardingproxy.Bootstrap.main(Bootstrap.java:68)
Caused by: Cannot create property=users for JavaBean=org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication@74ee003d
 in 'reader', line 2, column 3:
      users:
      ^
Unable to find property 'users' on class: org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication
 in 'reader', line 3, column 5:
        root: # username
        ^

    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:312)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:297)
    ... 11 more
Caused by: org.yaml.snakeyaml.error.YAMLException: Unable to find property 'users' on class: org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication
    at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:132)
    at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:121)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.getProperty(Constructor.java:322)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:240)
    ... 14 more

Hi @terrymanu @tristaZero , any progress?

Why you config password as password123test? what is your expected if you config a not existed config item?

It is just a bad format of yaml for sharding sphere's definition. I just close this issue.

@terrymanu
Sorry for my bad, I copied a wrong code, I have modified it.
The error still exists, password is not working, except for blank password. If using @tristaZero 's code, get error in log:

Exception in thread "main" Cannot create property=authentication for JavaBean=org.apache.shardingsphere.shardingproxy.config.yaml.YamlProxyServerConfiguration@3551e0c4
 in 'reader', line 1, column 1:
    authentication:
    ^
Cannot create property=users for JavaBean=org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication@74ee003d
 in 'reader', line 2, column 3:
      users:
      ^
Unable to find property 'users' on class: org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication
 in 'reader', line 3, column 5:
        root: # username
        ^

 in 'reader', line 2, column 3:
      users:
      ^

    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:312)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:345)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:141)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:127)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450)
    at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:410)
    at org.apache.shardingsphere.core.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:59)
    at org.apache.shardingsphere.shardingproxy.config.ShardingConfigurationLoader.loadServerConfiguration(ShardingConfigurationLoader.java:77)
    at org.apache.shardingsphere.shardingproxy.config.ShardingConfigurationLoader.load(ShardingConfigurationLoader.java:58)
    at org.apache.shardingsphere.shardingproxy.Bootstrap.main(Bootstrap.java:68)
Caused by: Cannot create property=users for JavaBean=org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication@74ee003d
 in 'reader', line 2, column 3:
      users:
      ^
Unable to find property 'users' on class: org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication
 in 'reader', line 3, column 5:
        root: # username
        ^

    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:312)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:297)
    ... 11 more
Caused by: org.yaml.snakeyaml.error.YAMLException: Unable to find property 'users' on class: org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication
    at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:132)
    at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:121)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.getProperty(Constructor.java:322)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:240)
    ... 14 more

same error using 4.0.0-RC1 when running it in docker

docker run -d --name sharding-proxy -v /d/docker/sharding-sphere/conf:/opt/sharding-proxy/conf --env PORT=3308 -p13308:3308 shardingsphere/sharding-proxy:latest

server.yaml

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

######################################################################################################
# 
# If you want to configure orchestration, authorization and proxy properties, please refer to this file.
# 
######################################################################################################

# orchestration:
#  name: orchestration_ds
#  overwrite: true
#  registry:
#    type: zookeeper
#    serverLists: localhost:2181
#    namespace: orchestration

authentication:
 users:
   root:
     password: root
   sharding:
     password: sharding 
     authorizedSchemas: sharding_db

props:
 max.connections.size.per.query: 1
 acceptor.size: 16  # The default value is available processors count * 2.
 executor.size: 16  # Infinite by default.
 proxy.frontend.flush.threshold: 128  # The default value is 128.
   # LOCAL: Proxy will run with LOCAL transaction.
   # XA: Proxy will run with XA transaction.
   # BASE: Proxy will run with B.A.S.E transaction.
 proxy.transaction.type: LOCAL
 proxy.opentracing.enabled: false
 sql.show: false

config-master_slave.yaml

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

######################################################################################################
# 
# Here you can configure the rules for the proxy.
# This example is configuration of master-slave rule.
#   
# If you want to use master-slave, please refer to this file; 
# if you want to use sharding, please refer to the config-sharding.yaml.
# if you want to use sharding, please refer to the config-encrypt.yaml.
# 
######################################################################################################
#
#schemaName: master_slave_db
#
#dataSources:
#  master_ds:
#    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_master?serverTimezone=UTC&useSSL=false
#    username: postgres
#    password: postgres
#    connectionTimeoutMilliseconds: 30000
#    idleTimeoutMilliseconds: 60000
#    maxLifetimeMilliseconds: 1800000
#    maxPoolSize: 50
#  slave_ds_0:
#    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_slave_0?serverTimezone=UTC&useSSL=false
#    username: postgres
#    password: postgres
#    connectionTimeoutMilliseconds: 30000
#    idleTimeoutMilliseconds: 60000
#    maxLifetimeMilliseconds: 1800000
#    maxPoolSize: 50
#  slave_ds_1:
#    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_slave_1?serverTimezone=UTC&useSSL=false
#    username: postgres
#    password: postgres
#    connectionTimeoutMilliseconds: 30000
#    idleTimeoutMilliseconds: 60000
#    maxLifetimeMilliseconds: 1800000
#    maxPoolSize: 50
#
#masterSlaveRule:
#  name: ms_ds
#  masterDataSourceName: master_ds
#  slaveDataSourceNames:
#    - slave_ds_0
#    - slave_ds_1

######################################################################################################
#
# If you want to connect to MySQL, you should manually copy MySQL driver to lib directory.
#
######################################################################################################

schemaName: master_slave_db

dataSources:
 master_ds:
   url: jdbc:mysql://localhost:3306/TestDatasource?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
   username: root
   password:
   connectionTimeoutMilliseconds: 30000
   idleTimeoutMilliseconds: 60000
   maxLifetimeMilliseconds: 1800000
   maxPoolSize: 50
 slave_ds_0:
   url: jdbc:mysql://127.0.0.1:3306/demo_ds_slave_0?serverTimezone=UTC&useSSL=false
   username: root
   password:
   connectionTimeoutMilliseconds: 30000
   idleTimeoutMilliseconds: 60000
   maxLifetimeMilliseconds: 1800000
   maxPoolSize: 50
 slave_ds_1:
   url: jdbc:mysql://127.0.0.1:3306/demo_ds_slave_1?serverTimezone=UTC&useSSL=false
   username: root
   password:
   connectionTimeoutMilliseconds: 30000
   idleTimeoutMilliseconds: 60000
   maxLifetimeMilliseconds: 1800000
   maxPoolSize: 50

masterSlaveRule:
 name: ms_ds
 masterDataSourceName: master_ds
 slaveDataSourceNames:
   - slave_ds_0
   - slave_ds_1

Hi @terrymanu @tristaZero , any update?
The problem still exists, this issue should not be closed.

Was this page helpful?
0 / 5 - 0 ratings