File tree Expand file tree Collapse file tree 5 files changed +51
-6
lines changed Expand file tree Collapse file tree 5 files changed +51
-6
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - Add ` JWT ` auth option (#656 ). This is a ClickHouse Cloud feature.
13+
14+ ### Changed
15+
16+ - Improved connection test (#655 ).
17+ - Updated dependencies.
18+
1019## [ 0.8.0] - 2024-11-11
1120
1221### Added
Original file line number Diff line number Diff line change 4949 "type" : " string" ,
5050 "default" : " default"
5151 },
52- "username " : {
53- "title " : " Username " ,
54- "type " : " string " ,
55- "default" : " default "
52+ "useJWT " : {
53+ "type " : " boolean " ,
54+ "title " : " Use JWT token instead of password " ,
55+ "default" : false
5656 },
5757 "passwordMode" : {
5858 "title" : " Password mode" ,
117117 }
118118 ]
119119 },
120+ "useJWT" : {
121+ "oneOf" : [
122+ {
123+ "properties" : {
124+ "useJWT" : {
125+ "enum" : [false ]
126+ },
127+ "username" : {
128+ "title" : " Username" ,
129+ "type" : " string" ,
130+ "default" : " default"
131+ }
132+ }
133+ },
134+ {
135+ "properties" : {
136+ "useJWT" : {
137+ "enum" : [true ]
138+ }
139+ }
140+ }
141+ ]
142+ },
120143 "enableTls" : {
121144 "oneOf" : [
122145 {
Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ export async function activate(
6969 connInfo . server = "http://" + connInfo . server ;
7070 }
7171
72+ if ( connInfo . useJWT ) {
73+ propsToRemove . push ( "username" ) ;
74+ }
75+
7276 if ( connInfo . passwordMode ) {
7377 if ( connInfo . passwordMode . toString ( ) . toLowerCase ( ) . includes ( "ask" ) ) {
7478 connInfo . askForPassword = true ;
Original file line number Diff line number Diff line change @@ -60,15 +60,20 @@ export default class ClickHouseDriver
6060
6161 const opts = {
6262 url : url ,
63- username : this . credentials . username ,
64- password : this . credentials . password ,
6563 role : this . credentials . role ,
6664 request_timeout : this . credentials . requestTimeout ,
6765 application : "sqltools-clickhouse-driver" ,
6866 database : this . credentials . database ,
6967 tls : tlsConfig ,
7068 } as ClickHouseClientConfigOptions ;
7169
70+ if ( this . credentials . useJWT ) {
71+ opts . access_token = this . credentials . password ;
72+ } else {
73+ opts . username = this . credentials . username ;
74+ opts . password = this . credentials . password ;
75+ }
76+
7277 this . connection = Promise . resolve ( createClient ( opts ) ) ;
7378 return this . connection ;
7479 }
Original file line number Diff line number Diff line change 33 " server" ,
44 " port" ,
55 " database" ,
6+ " useJWT" ,
67 " username" ,
78 " passwordMode" ,
89 " password" ,
1213 " tls"
1314 ],
1415 "password" : { "ui:widget" : " password" },
16+ "useJWT" : {
17+ "ui:help" : " This is a ClickHouse Cloud feature. Put token in password field"
18+ },
1519 "role" : {
1620 "ui:help" : " Only for ClickHouse >=24.4! See https://clickhouse.com/docs/en/interfaces/http#setting-role-with-query-parameters"
1721 },
You can’t perform that action at this time.
0 commit comments