1 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 2 // use this file except in compliance with the License. You may obtain a copy of 3 // the License at 4 // 5 // http://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 // License for the specific language governing permissions and limitations under 11 // the License. 12 13 package driver 14 15 import ( 16 "context" 17 "encoding/json" 18 ) 19 20 // Session is a copy of [github.com/go-kivik/kivik/v4.Session]. 21 type Session struct { 22 // Name is the name of the authenticated user. 23 Name string 24 // Roles is a list of roles the user belongs to. 25 Roles []string 26 // AuthenticationMethod is the authentication method that was used for this 27 // session. 28 AuthenticationMethod string 29 // AuthenticationDB is the user database against which authentication was 30 // performed. 31 AuthenticationDB string 32 // AuthenticationHandlers is a list of authentication handlers configured on 33 // the server. 34 AuthenticationHandlers []string 35 // RawResponse is the raw JSON response sent by the server, useful for 36 // custom backends which may provide additional fields. 37 RawResponse json.RawMessage 38 } 39 40 // Sessioner is an optional interface that a [Client] may satisfy to provide 41 // access to the authenticated session information. 42 type Sessioner interface { 43 // Session returns information about the authenticated user. 44 Session(ctx context.Context) (*Session, error) 45 } 46