Documentation ¶
Overview ¶
Copyright 2018 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2018 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2018 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func BuildHeader(tokenType string, token string) string
- func BuildRefreshCredentialsJSON(refreshToken string, credentialsJSON string) string
- func ClearCache() error
- func Curl(settings *sgauth.Settings, taskSettings *TaskSettings)
- func CurlCommand(cli string, header string, url string, extraArgs ...string)
- func EncodeClaims(settings *sgauth.Settings) string
- func Fetch(settings *sgauth.Settings, taskSettings *TaskSettings)
- func Header(settings *sgauth.Settings, taskSettings *TaskSettings)
- func Info(token string) int
- func InsertCache(settings *sgauth.Settings, token *sgauth.Token) error
- func LookupCache(settings *sgauth.Settings) (*sgauth.Token, error)
- func Reset()
- func SSOFetch(cli string, email string, scope string) (*sgauth.Token, error)
- func StsExchange(accessToken string, encodedClaims string) (*sgauth.Token, error)
- func Test(token string) int
- func Web()
- func WebStop()
- type CacheKey
- type TaskSettings
Constants ¶
const CacheFileName = ".oauth2l"
const StsURL = "https://securetoken.googleapis.com/v1alpha2/identitybindingtoken"
StsURL is Google's Secure Token Service endpoint used for obtaining STS token. TODO (andyzhao): Replace with https://sts.googleapis.com/v1/token when ready.
Variables ¶
var CacheLocation string = filepath.Join(sgauth.GuessUnixHomeDir(), CacheFileName)
var WebDirectory string = filepath.Join(sgauth.GuessUnixHomeDir(), defaultWebPackageName)
Functions ¶
func BuildHeader ¶
Returns the given token in standard header format.
func BuildRefreshCredentialsJSON ¶ added in v1.1.0
BuildRefreshCredentialsJSON attempts to construct a refreshCredentialsJSON using a refreshToken and an OAuth Client ID credentialsJSON. Empty string is returned if this is not possible.
func ClearCache ¶
func ClearCache() error
func Curl ¶
func Curl(settings *sgauth.Settings, taskSettings *TaskSettings)
Fetches token with the given settings using Google Authenticator and use the token as header to make curl request.
func CurlCommand ¶
Executes curl command with provided header and params.
func EncodeClaims ¶ added in v1.1.0
EncodeClaims base64 encodes supported STS claims in settings
func Fetch ¶
func Fetch(settings *sgauth.Settings, taskSettings *TaskSettings)
Fetches and prints the token in plain text with the given settings using Google Authenticator.
func Header ¶
func Header(settings *sgauth.Settings, taskSettings *TaskSettings)
Fetches and prints the token in header format with the given settings using Google Authenticator.
func StsExchange ¶ added in v1.1.0
Exchanges an OAuth Access Token to an Sts token with base64 encoded claims
Types ¶
type CacheKey ¶
type CacheKey struct { // The JSON credentials content downloaded from Google Cloud Console. CredentialsJSON string // If specified, use OAuth. Otherwise, JWT. Scope string // The audience field for JWT auth and UAT Audience string // The email used for SSO and domain-wide delegation. Email string // The Google API key APIKey string // The QuotaProject field for STS QuotaProject string // If specified, performs STS exchange on top of base OAuth Sts bool }
The key struct that used to identify an auth token fetch operation.
type TaskSettings ¶ added in v1.1.0
type TaskSettings struct { // Ouput format for Fetch task Format string // CurlCli override for Curl task CurlCli string // Url endpoint for Curl task Url string // Extra args for Curl task ExtraArgs []string // SsoCli override for Sso task SsoCli string // Refresh expired access token in cache Refresh bool }
An extensible structure that holds the settings used by different oauth2l tasks. These settings are used by oauth2l only and are not part of GUAC settings.