Skip to content

Commit

Permalink
Fix SQL Server connection with removing username/secret (#661)
Browse files Browse the repository at this point in the history
## Description
Enable Managed Identity authentication on Azure by doing the following:
- Updated DB Connection String
- Move redundant username/password from basic env yml to specific envs

<!-- A few words to explain your changes -->

### Linked GitHub issue ID: #  

## Pull Request Checklist
<!-- Put an x in the boxes that apply. This is simply a reminder of what
we are going to look for before merging your code. -->

- [X] Tests for the changes have been added (for bug fixes / features)
- [ ] Code compiles correctly with all tests are passed.
- [ ] I've read the [contributing
guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code)
and followed the recommended practices.
- [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or
[README](https://github.com/microsoft/HydraLab/blob/main/README.md) have
been reviewed and added / updated if needed (for bug fixes / features)

### Does this introduce a breaking change?
*If this introduces a breaking change for Hydra Lab users, please
describe the impact and migration path.*

- [ ] Yes
- [X] No

## How you tested it
*Please make sure the change is tested, you can test it by adding UTs,
do local test and share the screenshots, etc.*
Tested locally with local account, allocating the same permissions in DB
and run the app without error.

Please check the type of change your PR introduces:
- [ ] Bugfix
- [ ] Feature
- [ ] Technical design
- [ ] Build related changes
- [X] Refactoring (no functional changes, no api changes)
- [ ] Code style update (formatting, renaming) or Documentation content
changes
- [ ] Other (please describe): 

### Feature UI screenshots or Technical design diagrams
*If this is a relatively large or complex change, kick it off by drawing
the tech design with PlantUML and explaining why you chose the solution
you did and what alternatives you considered, etc...*

---------

Co-authored-by: MaX ES Bot <[email protected]>
  • Loading branch information
olivershen-wow and kabuqNo authored Jul 15, 2024
1 parent 4dc5eb4 commit c6988d8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
7 changes: 6 additions & 1 deletion center/application-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ spring:
redirect-uri: ${MICROSOFT_RERIRECT_URL}
ignore-uri: '/api/auth,/agent/connect'
scope: 'https://graph.microsoft.com/User.Read'

spring:
datasource:
url: jdbc:sqlite:${app.location}/hydra_lab_center_db.sqlite
driver-class-name: org.sqlite.JDBC
username: sqlite
password: 98765432
app:
# Mail Address Format
default-user: ${DEFAULT_USER}
Expand Down
2 changes: 1 addition & 1 deletion center/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {

compile group: 'org.apache.commons', name: 'commons-pool2', version: '2.7.0'

compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '7.4.0.jre8'
compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '12.6.1.jre8'
// compile group: 'org.postgresql', name: 'postgresql', version: '42.2.14'

compile group: 'org.springframework.security', name: 'spring-security-oauth2-client', version: '5.2.2.RELEASE'
Expand Down
3 changes: 3 additions & 0 deletions center/src/main/resources/application-docker.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
spring:
datasource:
url: jdbc:sqlite:${app.location}/hydra_lab_center_docker_db.sqlite
driver-class-name: org.sqlite.JDBC
username: sqlite
password: 98765432

app:
location: /hydra/data
6 changes: 2 additions & 4 deletions center/src/main/resources/application-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ spring:
authorization-grant-type: authorization_code
redirect-uri: ${MICROSOFT_RERIRECT_URL}
ignore-uri: '/api/auth,/agent/connect'
scope: 'https://graph.microsoft.com/User.Read'
scope: ${MICROSOFT_AUTH_SCOPE:openid+profile+email}
datasource:
url: ${DB_URL}
url: ${DB_URL} # UAMI integrated only
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
username: ${DB_NAME}
password: ${DB_PASS}
jpa:
database-platform: org.hibernate.dialect.SQLServer2012Dialect
show-sql: false
Expand Down
7 changes: 7 additions & 0 deletions center/src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
app:
default-user: '[email protected]'

spring:
datasource:
url: jdbc:sqlite:${app.location}/hydra_lab_center_db.sqlite
driver-class-name: org.sqlite.JDBC
username: sqlite
password: 98765432

management:
metrics:
export:
Expand Down
5 changes: 0 additions & 5 deletions center/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ spring:
multipart:
max-file-size: 1024MB
max-request-size: 2048MB
datasource:
url: jdbc:sqlite:${app.location}/hydra_lab_center_db.sqlite
username: sqlite
password: 98765432
driver-class-name: org.sqlite.JDBC
jpa:
database-platform: org.sqlite.hibernate.dialect.SQLiteDialect
show-sql: false
Expand Down
3 changes: 2 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ dependencies {
compile group: 'org.jsoup', name: 'jsoup', version: '1.10.1'
// https://docs.microsoft.com/en-us/graph/sdks/sdk-installation?context=graph%2Fapi%2F1.0&view=graph-rest-1.0
compile 'com.microsoft.graph:microsoft-graph:5.4.0'
implementation 'com.azure:azure-identity:1.13.0'
compile 'com.azure:azure-identity:1.11.1'
compile 'com.azure:azure-identity-broker:1.1.2'
//blob storage
compile 'com.azure:azure-storage-blob:12.23.0'
//Apk analysis
Expand Down

0 comments on commit c6988d8

Please sign in to comment.