github.com/greenpau/go-authcrunch@v1.1.4/pkg/requests/authz.go (about) 1 // Copyright 2022 Paul Greenberg greenpau@outlook.com 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package requests 16 17 // AuthorizationRequest hold the data associated with request authorization. 18 type AuthorizationRequest struct { 19 ID string `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"` 20 SessionID string `json:"session_id,omitempty" xml:"session_id,omitempty" yaml:"session_id,omitempty"` 21 Response AuthorizationResponse `json:"response,omitempty" xml:"response,omitempty" yaml:"response,omitempty"` 22 Redirect RedirectResponse `json:"-"` 23 Token AuthorizationToken `json:"-"` 24 } 25 26 // AuthorizationResponse holds the response associated with AuthorizationRequest. 27 type AuthorizationResponse struct { 28 User map[string]interface{} `json:"-"` 29 Authorized bool `json:"authorized" xml:"authorized" yaml:"authorized"` 30 Bypassed bool `json:"bypassed,omitempty" xml:"bypassed,omitempty" yaml:"bypassed,omitempty"` 31 Error error `json:"error,omitempty" xml:"error,omitempty" yaml:"error,omitempty"` 32 } 33 34 // AuthorizationToken holds the token found in an authorization request. 35 type AuthorizationToken struct { 36 Found bool `json:"found,omitempty" xml:"found,omitempty" yaml:"found,omitempty"` 37 Payload string `json:"payload,omitempty" xml:"payload,omitempty" yaml:"payload,omitempty"` 38 Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"` 39 Source string `json:"source,omitempty" xml:"source,omitempty" yaml:"source,omitempty"` 40 } 41 42 // RedirectResponse holds the redirect parameters associated with the 43 // response to AuthorizationRequest. 44 type RedirectResponse struct { 45 Enabled bool `json:"enabled,omitempty" xml:"enabled,omitempty" yaml:"enabled,omitempty"` 46 AuthURL string `json:"auth_url,omitempty" xml:"auth_url,omitempty" yaml:"auth_url,omitempty"` 47 Separator string `json:"separator,omitempty" xml:"separator,omitempty" yaml:"separator,omitempty"` 48 QueryParameter string `json:"query_parameter,omitempty" xml:"query_parameter,omitempty" yaml:"query_parameter,omitempty"` 49 QueryDisabled bool `json:"query_disabled,omitempty" xml:"query_disabled,omitempty" yaml:"query_disabled,omitempty"` 50 URL string `json:"url,omitempty" xml:"url,omitempty" yaml:"url,omitempty"` 51 StatusCode int `json:"status_code,omitempty" xml:"status_code,omitempty" yaml:"status_code,omitempty"` 52 LoginHint string `json:"login_hint,omitempty" xml:"login_hint,omitempty" yaml:"login_hint,omitempty"` 53 AdditionalScopes string `json:"additional_scopes,omitempty" xml:"additional_scopes,omitempty" yaml:"additional_scopes,omitempty"` 54 } 55 56 // NewAuthorizationRequest returns an instance of AuthorizationRequest. 57 func NewAuthorizationRequest() *AuthorizationRequest { 58 return &AuthorizationRequest{} 59 }