|
| 1 | +// Copyright 2024 Keyfactor |
| 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 | + |
1 | 15 | package auth_providers |
2 | 16 |
|
3 | 17 | import ( |
@@ -72,40 +86,34 @@ type CommandConfigOauth struct { |
72 | 86 | CommandAuthConfig |
73 | 87 |
|
74 | 88 | // ClientID is the Client ID for OAuth authentication |
75 | | - ClientID string `json:"client_id,omitempty"` |
| 89 | + ClientID string `json:"client_id,omitempty" yaml:"client_id,omitempty"` |
76 | 90 |
|
77 | 91 | // ClientSecret is the Client secret for OAuth authentication |
78 | | - ClientSecret string `json:"client_secret,omitempty"` |
| 92 | + ClientSecret string `json:"client_secret,omitempty" yaml:"client_secret,omitempty"` |
79 | 93 |
|
80 | 94 | // Audience is the audience for OAuth authentication |
81 | | - Audience string `json:"audience,omitempty"` |
| 95 | + Audience string `json:"audience,omitempty" yaml:"audience,omitempty"` |
82 | 96 |
|
83 | 97 | // Scopes is the scopes for OAuth authentication |
84 | | - Scopes []string `json:"scopes,omitempty"` |
| 98 | + Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"` |
85 | 99 |
|
86 | 100 | // CACertificatePath is the path to the CA certificate for OAuth authentication |
87 | | - CACertificatePath string `json:"idp_ca_cert,omitempty"` |
| 101 | + CACertificatePath string `json:"idp_ca_cert,omitempty" yaml:"idp_ca_cert,omitempty"` |
88 | 102 |
|
89 | 103 | // CACertificates is the CA certificates for authentication |
90 | 104 | CACertificates []*x509.Certificate `json:"-"` |
91 | 105 |
|
92 | 106 | // AccessToken is the access token for OAuth authentication |
93 | | - AccessToken string `json:"access_token,omitempty"` |
| 107 | + AccessToken string `json:"access_token,omitempty" yaml:"access_token,omitempty"` |
94 | 108 |
|
95 | 109 | // RefreshToken is the refresh token for OAuth authentication |
96 | | - RefreshToken string `json:"refresh_token,omitempty"` |
| 110 | + RefreshToken string `json:"refresh_token,omitempty" yaml:"refresh_token,omitempty"` |
97 | 111 |
|
98 | 112 | // Expiry is the expiry time of the access token |
99 | | - Expiry time.Time `json:"expiry,omitempty"` |
| 113 | + Expiry time.Time `json:"expiry,omitempty" yaml:"expiry,omitempty"` |
100 | 114 |
|
101 | 115 | // TokenURL is the token URL for OAuth authentication |
102 | | - TokenURL string `json:"token_url,omitempty"` |
103 | | - |
104 | | - //// AuthPort |
105 | | - //AuthPort string `json:"auth_port,omitempty"` |
106 | | - |
107 | | - //// AuthType is the type of OAuth auth to use such as client_credentials, password, etc. |
108 | | - //AuthType string `json:"auth_type,omitempty"` |
| 116 | + TokenURL string `json:"token_url,omitempty" yaml:"token_url,omitempty"` |
109 | 117 | } |
110 | 118 |
|
111 | 119 | // NewOAuthAuthenticatorBuilder creates a new CommandConfigOauth instance. |
@@ -372,7 +380,7 @@ func (b *CommandConfigOauth) ValidateAuthConfig() error { |
372 | 380 | } |
373 | 381 | } |
374 | 382 |
|
375 | | - if b.Scopes == nil || len(b.Scopes) == 0 { |
| 383 | + if len(b.Scopes) == 0 { |
376 | 384 | if scopes, ok := os.LookupEnv(EnvKeyfactorAuthScopes); ok { |
377 | 385 | // split the scopes by comma |
378 | 386 | b.Scopes = strings.Split(scopes, ",") |
@@ -424,6 +432,7 @@ func (b *CommandConfigOauth) GetServerConfig() *Server { |
424 | 432 | Port: b.CommandPort, |
425 | 433 | ClientID: b.ClientID, |
426 | 434 | ClientSecret: b.ClientSecret, |
| 435 | + AccessToken: b.AccessToken, |
427 | 436 | OAuthTokenUrl: b.TokenURL, |
428 | 437 | APIPath: b.CommandAPIPath, |
429 | 438 | Scopes: b.Scopes, |
|
0 commit comments