11import React , { ChangeEvent , PureComponent } from 'react' ;
2- import { DataSourceHttpSettings , InlineField , InlineSwitch , SecretInput } from '@grafana/ui' ;
2+ import { DataSourceHttpSettings , InlineField , InlineSwitch , SecretInput , Input } from '@grafana/ui' ;
33import { DataSourcePluginOptionsEditorProps } from '@grafana/data' ;
44import { TrinoDataSourceOptions , TrinoSecureJsonData } from './types' ;
55
@@ -19,6 +19,21 @@ export class ConfigEditor extends PureComponent<Props, State> {
1919 const onResetToken = ( ) => {
2020 onOptionsChange ( { ...options , secureJsonFields : { ...options . secureJsonFields , accessToken : false } , secureJsonData : { ...options . secureJsonData , accessToken : '' } } ) ;
2121 } ;
22+ const onTokenUrlChange = ( event : ChangeEvent < HTMLInputElement > ) => {
23+ onOptionsChange ( { ...options , jsonData : { ...options . jsonData , tokenUrl : event . target . value } } )
24+ } ;
25+ const onClientIdChange = ( event : ChangeEvent < HTMLInputElement > ) => {
26+ onOptionsChange ( { ...options , jsonData : { ...options . jsonData , clientId : event . target . value } } )
27+ } ;
28+ const onClientSecretChange = ( event : ChangeEvent < HTMLInputElement > ) => {
29+ onOptionsChange ( { ...options , secureJsonData : { ...options . secureJsonData , clientSecret : event . target . value } } )
30+ } ;
31+ const onResetClientSecret = ( ) => {
32+ onOptionsChange ( { ...options , secureJsonFields : { ...options . secureJsonFields , clientSecret : false } , secureJsonData : { ...options . secureJsonData , clientSecret : '' } } ) ;
33+ } ;
34+ const onImpersonationUserChange = ( event : ChangeEvent < HTMLInputElement > ) => {
35+ onOptionsChange ( { ...options , jsonData : { ...options . jsonData , impersonationUser : event . target . value } } )
36+ } ;
2237 return (
2338 < div className = "gf-form-group" >
2439 < DataSourceHttpSettings
@@ -58,6 +73,64 @@ export class ConfigEditor extends PureComponent<Props, State> {
5873 </ InlineField >
5974 </ div >
6075 </ div >
76+
77+ < h3 className = "page-heading" > OAuth Trino Authentication</ h3 >
78+ < div className = "gf-form-group" >
79+ < div className = "gf-form-inline" >
80+ < InlineField
81+ label = "Token URL"
82+ tooltip = "If set, token is retrieved by client credentials flow before request to Trino is sent"
83+ labelWidth = { 26 }
84+ >
85+ < Input
86+ value = { options . jsonData ?. tokenUrl ?? '' }
87+ onChange = { onTokenUrlChange }
88+ width = { 60 }
89+ />
90+ </ InlineField >
91+ </ div >
92+ < div className = "gf-form-inline" >
93+ < InlineField
94+ label = "Client id"
95+ tooltip = "Required if Token URL is set"
96+ labelWidth = { 26 }
97+ >
98+ < Input
99+ value = { options . jsonData ?. clientId ?? '' }
100+ onChange = { onClientIdChange }
101+ width = { 60 }
102+ />
103+ </ InlineField >
104+ </ div >
105+ < div className = "gf-form-inline" >
106+ < InlineField
107+ label = "Client secret"
108+ tooltip = "Required if Token URL is set"
109+ labelWidth = { 26 }
110+ >
111+ < SecretInput
112+ value = { options . secureJsonData ?. clientSecret ?? '' }
113+ isConfigured = { options . secureJsonFields ?. clientSecret }
114+ onChange = { onClientSecretChange }
115+ width = { 60 }
116+ onReset = { onResetClientSecret }
117+ />
118+ </ InlineField >
119+ </ div >
120+ < div className = "gf-form-inline" >
121+ < InlineField
122+ label = "Impersonation user"
123+ tooltip = "If set, this user will be used for impersonation in Trino"
124+ labelWidth = { 26 }
125+ >
126+ < Input
127+ value = { options . jsonData ?. impersonationUser ?? '' }
128+ onChange = { onImpersonationUserChange }
129+ width = { 60 }
130+ />
131+ </ InlineField >
132+ </ div >
133+ </ div >
61134 </ div >
62135 ) ;
63136 }
0 commit comments