apache / apache/grails-core

passwordEncryptionCodec doesn't work in 3.3

Open
#10,714 5 comments 0 reactions 0 assignees View on GitHub
info: workaround available
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

In Grails 3.2.x, you can use an encoded password for data source if you set `passwordEncryptionCodec` in configuration file like this:

```yml
// in application.yml
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
#password: password
password: PASSWORD
passwordEncryptionCodec: UppercaseCodec
# See https://github.com/nobeans/grails-issues/blob/master/g3211-passwordEncryptionCodec/grails-app/utils/UppercaseCodec.groovy
```

But a code for this feature was removed at 457b5412f0739d9acb7773f896ab319b68a32c63 (commented as "Use the DataSourceConnectionSourceFactory to create the datasources").
In the commit, the code using `passwordEncryptionCodec` in `DataSourceGrailsPlugin` was replaced with a code just using `org.grails.datastore.gorm.jdbc.connections.DataSourceConnectionSourceFactory`.

### Task List

- [x] Steps to reproduce provided
- [ ] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)

### Steps to Reproduce

1. Implement your Codec class (like `UppercaseCodec`.)
2. Configure to use `passwordEncryptionCodec` in `application.yml`.
3. Run the application.
4. Access to `http://localhost:8080/dbconsole/`.
5. Input the word `password` (lower-case) in `Password` field.
6. Click `Test Connection` button.

### Expected Behaviour

The message `Test successful` is shown in the bottom.

### Actual Behaviour

The error message `Wrong user name or password [28000-195] 28000/28000` is shown in the bottom.
If you use the word `PASSWORD` (upper-case), you can see the message `Test successful`.

### Environment Information

- **Operating System**: macOS 10.12.5
- **Grails Version**: 3.3.0.RC1
- **JDK Version**: 1.8.0_131

### Example Application

- In Grails 3.2.11, it works well expectedly: https://github.com/nobeans/grails-issues/tree/master/g3211-passwordEncryptionCodec
- In Grails 3.3.0.RC1, nothing occurs: https://github.com/nobeans/grails-issues/tree/b6c2151/g330rc1-passwordEncryptionCodec

Contributor guide

Open the contributing guide

Research direction

Start by comparing the password handling in DataSourceGrailsPlugin before and after the referenced change to DataSourceConnectionSourceFactory. Run the linked Grails 3.3.0.RC1 example with passwordEncryptionCodec configured, then verify that entering the unencoded password succeeds in the dbconsole as it does in the Grails 3.2.11 example.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.