github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/tequilapi/contract/auth.go (about) 1 /* 2 * Copyright (C) 2020 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package contract 19 20 import ( 21 "time" 22 23 "github.com/mysteriumnetwork/node/core/auth" 24 ) 25 26 // AuthRequest request used to authenticate to API. 27 // swagger:model AuthRequest 28 type AuthRequest struct { 29 Username string `json:"username"` 30 Password string `json:"password"` 31 } 32 33 // NewAuthResponse maps to API authentication response. 34 func NewAuthResponse(jwtToken auth.JWT) AuthResponse { 35 return AuthResponse{ 36 Token: jwtToken.Token, 37 ExpiresAt: jwtToken.ExpirationTime.Format(time.RFC3339), 38 } 39 } 40 41 // AuthResponse response after successful authentication to API. 42 // swagger:model AuthResponse 43 type AuthResponse struct { 44 // example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Im15c3QiLCJleHAiOjE2MDEwNDA1NzB9.hnn9FosblyWtx1feSupx3MhZZdkbCuMTaiM6xl54VwQ 45 Token string `json:"token"` 46 47 // example: 2019-06-06T11:04:43.910035Z 48 ExpiresAt string `json:"expires_at"` 49 } 50 51 // ChangePasswordRequest request used to change API password. 52 // swagger:model ChangePasswordRequest 53 type ChangePasswordRequest struct { 54 Username string `json:"username"` 55 OldPassword string `json:"old_password"` 56 NewPassword string `json:"new_password"` 57 }