Update dependencies (#7331)
* Update dependencies Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in> * Update protos Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>pull/7341/head
parent
ff80690a6e
commit
c729df3d0f
24
vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/assume_role_provider.go
generated
vendored
24
vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/assume_role_provider.go
generated
vendored
2
vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/web_identity_provider.go
generated
vendored
2
vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/web_identity_provider.go
generated
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
88
vendor/github.com/golang/protobuf/protoc-gen-go/generator/internal/remap/remap.go
generated
vendored
88
vendor/github.com/golang/protobuf/protoc-gen-go/generator/internal/remap/remap.go
generated
vendored
@ -1,88 +0,0 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package remap handles tracking the locations of Go tokens in a source text
|
||||
// across a rewrite by the Go formatter.
|
||||
package remap |
||||
|
||||
import ( |
||||
"fmt" |
||||
"go/scanner" |
||||
"go/token" |
||||
) |
||||
|
||||
// A Location represents a span of byte offsets in the source text.
|
||||
type Location struct { |
||||
Pos, End int // End is exclusive
|
||||
} |
||||
|
||||
// A Map represents a mapping between token locations in an input source text
|
||||
// and locations in the correspnding output text.
|
||||
type Map map[Location]Location |
||||
|
||||
// Find reports whether the specified span is recorded by m, and if so returns
|
||||
// the new location it was mapped to. If the input span was not found, the
|
||||
// returned location is the same as the input.
|
||||
func (m Map) Find(pos, end int) (Location, bool) { |
||||
key := Location{ |
||||
Pos: pos, |
||||
End: end, |
||||
} |
||||
if loc, ok := m[key]; ok { |
||||
return loc, true |
||||
} |
||||
return key, false |
||||
} |
||||
|
||||
func (m Map) add(opos, oend, npos, nend int) { |
||||
m[Location{Pos: opos, End: oend}] = Location{Pos: npos, End: nend} |
||||
} |
||||
|
||||
// Compute constructs a location mapping from input to output. An error is
|
||||
// reported if any of the tokens of output cannot be mapped.
|
||||
func Compute(input, output []byte) (Map, error) { |
||||
itok := tokenize(input) |
||||
otok := tokenize(output) |
||||
if len(itok) != len(otok) { |
||||
return nil, fmt.Errorf("wrong number of tokens, %d ≠ %d", len(itok), len(otok)) |
||||
} |
||||
m := make(Map) |
||||
for i, ti := range itok { |
||||
to := otok[i] |
||||
if ti.Token != to.Token { |
||||
return nil, fmt.Errorf("token %d type mismatch: %s ≠ %s", i+1, ti, to) |
||||
} |
||||
m.add(ti.pos, ti.end, to.pos, to.end) |
||||
} |
||||
return m, nil |
||||
} |
||||
|
||||
// tokinfo records the span and type of a source token.
|
||||
type tokinfo struct { |
||||
pos, end int |
||||
token.Token |
||||
} |
||||
|
||||
func tokenize(src []byte) []tokinfo { |
||||
fs := token.NewFileSet() |
||||
var s scanner.Scanner |
||||
s.Init(fs.AddFile("src", fs.Base(), len(src)), src, nil, scanner.ScanComments) |
||||
var info []tokinfo |
||||
for { |
||||
pos, next, lit := s.Scan() |
||||
switch next { |
||||
case token.SEMICOLON: |
||||
continue |
||||
} |
||||
info = append(info, tokinfo{ |
||||
pos: int(pos - 1), |
||||
end: int(pos + token.Pos(len(lit)) - 1), |
||||
Token: next, |
||||
}) |
||||
if next == token.EOF { |
||||
break |
||||
} |
||||
} |
||||
return info |
||||
} |
||||
62
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go
generated
vendored
62
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go
generated
vendored
12
vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/requests.go
generated
vendored
12
vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/requests.go
generated
vendored
6
vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/requests.go
generated
vendored
6
vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/requests.go
generated
vendored
123
vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/doc.go
generated
vendored
123
vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/doc.go
generated
vendored
@ -0,0 +1,123 @@ |
||||
/* |
||||
Package oauth1 enables management of OpenStack OAuth1 tokens and Authentication. |
||||
|
||||
Example to Create an OAuth1 Consumer |
||||
|
||||
createConsumerOpts := oauth1.CreateConsumerOpts{ |
||||
Description: "My consumer", |
||||
} |
||||
consumer, err := oauth1.CreateConsumer(identityClient, createConsumerOpts).Extract() |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
// NOTE: Consumer secret is available only on create response
|
||||
fmt.Printf("Consumer: %+v\n", consumer) |
||||
|
||||
Example to Request an unauthorized OAuth1 token |
||||
|
||||
requestTokenOpts := oauth1.RequestTokenOpts{ |
||||
OAuthConsumerKey: consumer.ID, |
||||
OAuthConsumerSecret: consumer.Secret, |
||||
OAuthSignatureMethod: oauth1.HMACSHA1, |
||||
RequestedProjectID: projectID, |
||||
} |
||||
requestToken, err := oauth1.RequestToken(identityClient, requestTokenOpts).Extract() |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
// NOTE: Request token secret is available only on request response
|
||||
fmt.Printf("Request token: %+v\n", requestToken) |
||||
|
||||
Example to Authorize an unauthorized OAuth1 token |
||||
|
||||
authorizeTokenOpts := oauth1.AuthorizeTokenOpts{ |
||||
Roles: []oauth1.Role{ |
||||
{Name: "member"}, |
||||
}, |
||||
} |
||||
authToken, err := oauth1.AuthorizeToken(identityClient, requestToken.OAuthToken, authorizeTokenOpts).Extract() |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
fmt.Printf("Verifier ID of the unauthorized Token: %+v\n", authToken.OAuthVerifier) |
||||
|
||||
Example to Create an OAuth1 Access Token |
||||
|
||||
accessTokenOpts := oauth1.CreateAccessTokenOpts{ |
||||
OAuthConsumerKey: consumer.ID, |
||||
OAuthConsumerSecret: consumer.Secret, |
||||
OAuthToken: requestToken.OAuthToken, |
||||
OAuthTokenSecret: requestToken.OAuthTokenSecret, |
||||
OAuthVerifier: authToken.OAuthVerifier, |
||||
OAuthSignatureMethod: oauth1.HMACSHA1, |
||||
} |
||||
accessToken, err := oauth1.CreateAccessToken(identityClient, accessTokenOpts).Extract() |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
// NOTE: Access token secret is available only on create response
|
||||
fmt.Printf("OAuth1 Access Token: %+v\n", accessToken) |
||||
|
||||
Example to List User's OAuth1 Access Tokens |
||||
|
||||
allPages, err := oauth1.ListAccessTokens(identityClient, userID).AllPages() |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
accessTokens, err := oauth1.ExtractAccessTokens(allPages) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
for _, accessToken := range accessTokens { |
||||
fmt.Printf("Access Token: %+v\n", accessToken) |
||||
} |
||||
|
||||
Example to Authenticate a client using OAuth1 method |
||||
|
||||
client, err := openstack.NewClient("http://localhost:5000/v3") |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
authOptions := &oauth1.AuthOptions{ |
||||
// consumer token, created earlier
|
||||
OAuthConsumerKey: consumer.ID, |
||||
OAuthConsumerSecret: consumer.Secret, |
||||
// access token, created earlier
|
||||
OAuthToken: accessToken.OAuthToken, |
||||
OAuthTokenSecret: accessToken.OAuthTokenSecret, |
||||
OAuthSignatureMethod: oauth1.HMACSHA1, |
||||
} |
||||
err = openstack.AuthenticateV3(client, authOptions, gophercloud.EndpointOpts{}) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
Example to Create a Token using OAuth1 method |
||||
|
||||
var oauth1Token struct { |
||||
tokens.Token |
||||
oauth1.TokenExt |
||||
} |
||||
|
||||
createOpts := &oauth1.AuthOptions{ |
||||
// consumer token, created earlier
|
||||
OAuthConsumerKey: consumer.ID, |
||||
OAuthConsumerSecret: consumer.Secret, |
||||
// access token, created earlier
|
||||
OAuthToken: accessToken.OAuthToken, |
||||
OAuthTokenSecret: accessToken.OAuthTokenSecret, |
||||
OAuthSignatureMethod: oauth1.HMACSHA1, |
||||
} |
||||
err := tokens.Create(identityClient, createOpts).ExtractInto(&oauth1Token) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
*/ |
||||
package oauth1 |
||||
@ -0,0 +1,587 @@ |
||||
package oauth1 |
||||
|
||||
import ( |
||||
"crypto/hmac" |
||||
"crypto/sha1" |
||||
"encoding/base64" |
||||
"fmt" |
||||
"io/ioutil" |
||||
"math/rand" |
||||
"net/url" |
||||
"sort" |
||||
"strconv" |
||||
"strings" |
||||
"time" |
||||
|
||||
"github.com/gophercloud/gophercloud" |
||||
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" |
||||
"github.com/gophercloud/gophercloud/pagination" |
||||
) |
||||
|
||||
// Type SignatureMethod is a OAuth1 SignatureMethod type.
|
||||
type SignatureMethod string |
||||
|
||||
const ( |
||||
// HMACSHA1 is a recommended OAuth1 signature method.
|
||||
HMACSHA1 SignatureMethod = "HMAC-SHA1" |
||||
|
||||
// PLAINTEXT signature method is not recommended to be used in
|
||||
// production environment.
|
||||
PLAINTEXT SignatureMethod = "PLAINTEXT" |
||||
|
||||
// OAuth1TokenContentType is a supported content type for an OAuth1
|
||||
// token.
|
||||
OAuth1TokenContentType = "application/x-www-form-urlencoded" |
||||
) |
||||
|
||||
// AuthOptions represents options for authenticating a user using OAuth1 tokens.
|
||||
type AuthOptions struct { |
||||
// OAuthConsumerKey is the OAuth1 Consumer Key.
|
||||
OAuthConsumerKey string `q:"oauth_consumer_key" required:"true"` |
||||
|
||||
// OAuthConsumerSecret is the OAuth1 Consumer Secret. Used to generate
|
||||
// an OAuth1 request signature.
|
||||
OAuthConsumerSecret string `required:"true"` |
||||
|
||||
// OAuthToken is the OAuth1 Request Token.
|
||||
OAuthToken string `q:"oauth_token" required:"true"` |
||||
|
||||
// OAuthTokenSecret is the OAuth1 Request Token Secret. Used to generate
|
||||
// an OAuth1 request signature.
|
||||
OAuthTokenSecret string `required:"true"` |
||||
|
||||
// OAuthSignatureMethod is the OAuth1 signature method the Consumer used
|
||||
// to sign the request. Supported values are "HMAC-SHA1" or "PLAINTEXT".
|
||||
// "PLAINTEXT" is not recommended for production usage.
|
||||
OAuthSignatureMethod SignatureMethod `q:"oauth_signature_method" required:"true"` |
||||
|
||||
// OAuthTimestamp is an OAuth1 request timestamp. If nil, current Unix
|
||||
// timestamp will be used.
|
||||
OAuthTimestamp *time.Time |
||||
|
||||
// OAuthNonce is an OAuth1 request nonce. Nonce must be a random string,
|
||||
// uniquely generated for each request. Will be generated automatically
|
||||
// when it is not set.
|
||||
OAuthNonce string `q:"oauth_nonce"` |
||||
|
||||
// AllowReauth allows Gophercloud to re-authenticate automatically
|
||||
// if/when your token expires.
|
||||
AllowReauth bool |
||||
} |
||||
|
||||
// ToTokenV3HeadersMap builds the headers required for an OAuth1-based create
|
||||
// request.
|
||||
func (opts AuthOptions) ToTokenV3HeadersMap(headerOpts map[string]interface{}) (map[string]string, error) { |
||||
q, err := buildOAuth1QueryString(opts, opts.OAuthTimestamp, "") |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
signatureKeys := []string{opts.OAuthConsumerSecret, opts.OAuthTokenSecret} |
||||
|
||||
method := headerOpts["method"].(string) |
||||
u := headerOpts["url"].(string) |
||||
stringToSign := buildStringToSign(method, u, q.Query()) |
||||
signature := url.QueryEscape(signString(opts.OAuthSignatureMethod, stringToSign, signatureKeys)) |
||||
|
||||
authHeader := buildAuthHeader(q.Query(), signature) |
||||
|
||||
headers := map[string]string{ |
||||
"Authorization": authHeader, |
||||
"X-Auth-Token": "", |
||||
} |
||||
|
||||
return headers, nil |
||||
} |
||||
|
||||
// ToTokenV3ScopeMap allows AuthOptions to satisfy the tokens.AuthOptionsBuilder
|
||||
// interface.
|
||||
func (opts AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { |
||||
return nil, nil |
||||
} |
||||
|
||||
// CanReauth allows AuthOptions to satisfy the tokens.AuthOptionsBuilder
|
||||
// interface.
|
||||
func (opts AuthOptions) CanReauth() bool { |
||||
return opts.AllowReauth |
||||
} |
||||
|
||||
// ToTokenV3CreateMap builds a create request body.
|
||||
func (opts AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string]interface{}, error) { |
||||
// identityReq defines the "identity" portion of an OAuth1-based authentication
|
||||
// create request body.
|
||||
type identityReq struct { |
||||
Methods []string `json:"methods"` |
||||
OAuth1 struct{} `json:"oauth1"` |
||||
} |
||||
|
||||
// authReq defines the "auth" portion of an OAuth1-based authentication
|
||||
// create request body.
|
||||
type authReq struct { |
||||
Identity identityReq `json:"identity"` |
||||
} |
||||
|
||||
// oauth1Request defines how an OAuth1-based authentication create
|
||||
// request body looks.
|
||||
type oauth1Request struct { |
||||
Auth authReq `json:"auth"` |
||||
} |
||||
|
||||
var req oauth1Request |
||||
|
||||
req.Auth.Identity.Methods = []string{"oauth1"} |
||||
return gophercloud.BuildRequestBody(req, "") |
||||
} |
||||
|
||||
// Create authenticates and either generates a new OpenStack token from an
|
||||
// OAuth1 token.
|
||||
func Create(client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { |
||||
b, err := opts.ToTokenV3CreateMap(nil) |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
|
||||
headerOpts := map[string]interface{}{ |
||||
"method": "POST", |
||||
"url": authURL(client), |
||||
} |
||||
|
||||
h, err := opts.ToTokenV3HeadersMap(headerOpts) |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
|
||||
resp, err := client.Post(authURL(client), b, &r.Body, &gophercloud.RequestOpts{ |
||||
MoreHeaders: h, |
||||
OkCodes: []int{201}, |
||||
}) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// CreateConsumerOptsBuilder allows extensions to add additional parameters to
|
||||
// the CreateConsumer request.
|
||||
type CreateConsumerOptsBuilder interface { |
||||
ToOAuth1CreateConsumerMap() (map[string]interface{}, error) |
||||
} |
||||
|
||||
// CreateConsumerOpts provides options used to create a new Consumer.
|
||||
type CreateConsumerOpts struct { |
||||
// Description is the consumer description.
|
||||
Description string `json:"description"` |
||||
} |
||||
|
||||
// ToOAuth1CreateConsumerMap formats a CreateConsumerOpts into a create request.
|
||||
func (opts CreateConsumerOpts) ToOAuth1CreateConsumerMap() (map[string]interface{}, error) { |
||||
return gophercloud.BuildRequestBody(opts, "consumer") |
||||
} |
||||
|
||||
// Create creates a new Consumer.
|
||||
func CreateConsumer(client *gophercloud.ServiceClient, opts CreateConsumerOptsBuilder) (r CreateConsumerResult) { |
||||
b, err := opts.ToOAuth1CreateConsumerMap() |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
resp, err := client.Post(consumersURL(client), b, &r.Body, &gophercloud.RequestOpts{ |
||||
OkCodes: []int{201}, |
||||
}) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// Delete deletes a Consumer.
|
||||
func DeleteConsumer(client *gophercloud.ServiceClient, id string) (r DeleteConsumerResult) { |
||||
resp, err := client.Delete(consumerURL(client, id), nil) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// List enumerates Consumers.
|
||||
func ListConsumers(client *gophercloud.ServiceClient) pagination.Pager { |
||||
return pagination.NewPager(client, consumersURL(client), func(r pagination.PageResult) pagination.Page { |
||||
return ConsumersPage{pagination.LinkedPageBase{PageResult: r}} |
||||
}) |
||||
} |
||||
|
||||
// GetConsumer retrieves details on a single Consumer by ID.
|
||||
func GetConsumer(client *gophercloud.ServiceClient, id string) (r GetConsumerResult) { |
||||
resp, err := client.Get(consumerURL(client, id), &r.Body, nil) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// UpdateConsumerOpts provides options used to update a consumer.
|
||||
type UpdateConsumerOpts struct { |
||||
// Description is the consumer description.
|
||||
Description string `json:"description"` |
||||
} |
||||
|
||||
// ToOAuth1UpdateConsumerMap formats an UpdateConsumerOpts into a consumer update
|
||||
// request.
|
||||
func (opts UpdateConsumerOpts) ToOAuth1UpdateConsumerMap() (map[string]interface{}, error) { |
||||
return gophercloud.BuildRequestBody(opts, "consumer") |
||||
} |
||||
|
||||
// UpdateConsumer updates an existing Consumer.
|
||||
func UpdateConsumer(client *gophercloud.ServiceClient, id string, opts UpdateConsumerOpts) (r UpdateConsumerResult) { |
||||
b, err := opts.ToOAuth1UpdateConsumerMap() |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
resp, err := client.Patch(consumerURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ |
||||
OkCodes: []int{200}, |
||||
}) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// RequestTokenOptsBuilder allows extensions to add additional parameters to the
|
||||
// RequestToken request.
|
||||
type RequestTokenOptsBuilder interface { |
||||
ToOAuth1RequestTokenHeaders(string, string) (map[string]string, error) |
||||
} |
||||
|
||||
// RequestTokenOpts provides options used to get a consumer unauthorized
|
||||
// request token.
|
||||
type RequestTokenOpts struct { |
||||
// OAuthConsumerKey is the OAuth1 Consumer Key.
|
||||
OAuthConsumerKey string `q:"oauth_consumer_key" required:"true"` |
||||
|
||||
// OAuthConsumerSecret is the OAuth1 Consumer Secret. Used to generate
|
||||
// an OAuth1 request signature.
|
||||
OAuthConsumerSecret string `required:"true"` |
||||
|
||||
// OAuthSignatureMethod is the OAuth1 signature method the Consumer used
|
||||
// to sign the request. Supported values are "HMAC-SHA1" or "PLAINTEXT".
|
||||
// "PLAINTEXT" is not recommended for production usage.
|
||||
OAuthSignatureMethod SignatureMethod `q:"oauth_signature_method" required:"true"` |
||||
|
||||
// OAuthTimestamp is an OAuth1 request timestamp. If nil, current Unix
|
||||
// timestamp will be used.
|
||||
OAuthTimestamp *time.Time |
||||
|
||||
// OAuthNonce is an OAuth1 request nonce. Nonce must be a random string,
|
||||
// uniquely generated for each request. Will be generated automatically
|
||||
// when it is not set.
|
||||
OAuthNonce string `q:"oauth_nonce"` |
||||
|
||||
// RequestedProjectID is a Project ID a consumer user requested an
|
||||
// access to.
|
||||
RequestedProjectID string `h:"Requested-Project-Id"` |
||||
} |
||||
|
||||
// ToOAuth1RequestTokenHeaders formats a RequestTokenOpts into a map of request
|
||||
// headers.
|
||||
func (opts RequestTokenOpts) ToOAuth1RequestTokenHeaders(method, u string) (map[string]string, error) { |
||||
q, err := buildOAuth1QueryString(opts, opts.OAuthTimestamp, "oob") |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
h, err := gophercloud.BuildHeaders(opts) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
signatureKeys := []string{opts.OAuthConsumerSecret} |
||||
stringToSign := buildStringToSign(method, u, q.Query()) |
||||
signature := url.QueryEscape(signString(opts.OAuthSignatureMethod, stringToSign, signatureKeys)) |
||||
authHeader := buildAuthHeader(q.Query(), signature) |
||||
|
||||
h["Authorization"] = authHeader |
||||
|
||||
return h, nil |
||||
} |
||||
|
||||
// RequestToken requests an unauthorized OAuth1 Token.
|
||||
func RequestToken(client *gophercloud.ServiceClient, opts RequestTokenOptsBuilder) (r TokenResult) { |
||||
h, err := opts.ToOAuth1RequestTokenHeaders("POST", requestTokenURL(client)) |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
|
||||
resp, err := client.Post(requestTokenURL(client), nil, nil, &gophercloud.RequestOpts{ |
||||
MoreHeaders: h, |
||||
OkCodes: []int{201}, |
||||
KeepResponseBody: true, |
||||
}) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
if r.Err != nil { |
||||
return |
||||
} |
||||
defer resp.Body.Close() |
||||
if v := r.Header.Get("Content-Type"); v != OAuth1TokenContentType { |
||||
r.Err = fmt.Errorf("unsupported Content-Type: %q", v) |
||||
return |
||||
} |
||||
r.Body, r.Err = ioutil.ReadAll(resp.Body) |
||||
return |
||||
} |
||||
|
||||
// AuthorizeTokenOptsBuilder allows extensions to add additional parameters to
|
||||
// the AuthorizeToken request.
|
||||
type AuthorizeTokenOptsBuilder interface { |
||||
ToOAuth1AuthorizeTokenMap() (map[string]interface{}, error) |
||||
} |
||||
|
||||
// AuthorizeTokenOpts provides options used to authorize a request token.
|
||||
type AuthorizeTokenOpts struct { |
||||
Roles []Role `json:"roles"` |
||||
} |
||||
|
||||
// Role is a struct representing a role object in a AuthorizeTokenOpts struct.
|
||||
type Role struct { |
||||
ID string `json:"id,omitempty"` |
||||
Name string `json:"name,omitempty"` |
||||
} |
||||
|
||||
// ToOAuth1AuthorizeTokenMap formats an AuthorizeTokenOpts into an authorize token
|
||||
// request.
|
||||
func (opts AuthorizeTokenOpts) ToOAuth1AuthorizeTokenMap() (map[string]interface{}, error) { |
||||
for _, r := range opts.Roles { |
||||
if r == (Role{}) { |
||||
return nil, fmt.Errorf("role must not be empty") |
||||
} |
||||
} |
||||
return gophercloud.BuildRequestBody(opts, "") |
||||
} |
||||
|
||||
// AuthorizeToken authorizes an unauthorized consumer token.
|
||||
func AuthorizeToken(client *gophercloud.ServiceClient, id string, opts AuthorizeTokenOptsBuilder) (r AuthorizeTokenResult) { |
||||
b, err := opts.ToOAuth1AuthorizeTokenMap() |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
resp, err := client.Put(authorizeTokenURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ |
||||
OkCodes: []int{200}, |
||||
}) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// CreateAccessTokenOptsBuilder allows extensions to add additional parameters
|
||||
// to the CreateAccessToken request.
|
||||
type CreateAccessTokenOptsBuilder interface { |
||||
ToOAuth1CreateAccessTokenHeaders(string, string) (map[string]string, error) |
||||
} |
||||
|
||||
// CreateAccessTokenOpts provides options used to create an OAuth1 token.
|
||||
type CreateAccessTokenOpts struct { |
||||
// OAuthConsumerKey is the OAuth1 Consumer Key.
|
||||
OAuthConsumerKey string `q:"oauth_consumer_key" required:"true"` |
||||
|
||||
// OAuthConsumerSecret is the OAuth1 Consumer Secret. Used to generate
|
||||
// an OAuth1 request signature.
|
||||
OAuthConsumerSecret string `required:"true"` |
||||
|
||||
// OAuthToken is the OAuth1 Request Token.
|
||||
OAuthToken string `q:"oauth_token" required:"true"` |
||||
|
||||
// OAuthTokenSecret is the OAuth1 Request Token Secret. Used to generate
|
||||
// an OAuth1 request signature.
|
||||
OAuthTokenSecret string `required:"true"` |
||||
|
||||
// OAuthVerifier is the OAuth1 verification code.
|
||||
OAuthVerifier string `q:"oauth_verifier" required:"true"` |
||||
|
||||
// OAuthSignatureMethod is the OAuth1 signature method the Consumer used
|
||||
// to sign the request. Supported values are "HMAC-SHA1" or "PLAINTEXT".
|
||||
// "PLAINTEXT" is not recommended for production usage.
|
||||
OAuthSignatureMethod SignatureMethod `q:"oauth_signature_method" required:"true"` |
||||
|
||||
// OAuthTimestamp is an OAuth1 request timestamp. If nil, current Unix
|
||||
// timestamp will be used.
|
||||
OAuthTimestamp *time.Time |
||||
|
||||
// OAuthNonce is an OAuth1 request nonce. Nonce must be a random string,
|
||||
// uniquely generated for each request. Will be generated automatically
|
||||
// when it is not set.
|
||||
OAuthNonce string `q:"oauth_nonce"` |
||||
} |
||||
|
||||
// ToOAuth1CreateAccessTokenHeaders formats a CreateAccessTokenOpts into a map of
|
||||
// request headers.
|
||||
func (opts CreateAccessTokenOpts) ToOAuth1CreateAccessTokenHeaders(method, u string) (map[string]string, error) { |
||||
q, err := buildOAuth1QueryString(opts, opts.OAuthTimestamp, "") |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
signatureKeys := []string{opts.OAuthConsumerSecret, opts.OAuthTokenSecret} |
||||
stringToSign := buildStringToSign(method, u, q.Query()) |
||||
signature := url.QueryEscape(signString(opts.OAuthSignatureMethod, stringToSign, signatureKeys)) |
||||
authHeader := buildAuthHeader(q.Query(), signature) |
||||
|
||||
headers := map[string]string{ |
||||
"Authorization": authHeader, |
||||
} |
||||
|
||||
return headers, nil |
||||
} |
||||
|
||||
// CreateAccessToken creates a new OAuth1 Access Token
|
||||
func CreateAccessToken(client *gophercloud.ServiceClient, opts CreateAccessTokenOptsBuilder) (r TokenResult) { |
||||
h, err := opts.ToOAuth1CreateAccessTokenHeaders("POST", createAccessTokenURL(client)) |
||||
if err != nil { |
||||
r.Err = err |
||||
return |
||||
} |
||||
|
||||
resp, err := client.Post(createAccessTokenURL(client), nil, nil, &gophercloud.RequestOpts{ |
||||
MoreHeaders: h, |
||||
OkCodes: []int{201}, |
||||
KeepResponseBody: true, |
||||
}) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
if r.Err != nil { |
||||
return |
||||
} |
||||
defer resp.Body.Close() |
||||
if v := r.Header.Get("Content-Type"); v != OAuth1TokenContentType { |
||||
r.Err = fmt.Errorf("unsupported Content-Type: %q", v) |
||||
return |
||||
} |
||||
r.Body, r.Err = ioutil.ReadAll(resp.Body) |
||||
return |
||||
} |
||||
|
||||
// GetAccessToken retrieves details on a single OAuth1 access token by an ID.
|
||||
func GetAccessToken(client *gophercloud.ServiceClient, userID string, id string) (r GetAccessTokenResult) { |
||||
resp, err := client.Get(userAccessTokenURL(client, userID, id), &r.Body, nil) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// RevokeAccessToken revokes an OAuth1 access token.
|
||||
func RevokeAccessToken(client *gophercloud.ServiceClient, userID string, id string) (r RevokeAccessTokenResult) { |
||||
resp, err := client.Delete(userAccessTokenURL(client, userID, id), nil) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// ListAccessTokens enumerates authorized access tokens.
|
||||
func ListAccessTokens(client *gophercloud.ServiceClient, userID string) pagination.Pager { |
||||
url := userAccessTokensURL(client, userID) |
||||
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { |
||||
return AccessTokensPage{pagination.LinkedPageBase{PageResult: r}} |
||||
}) |
||||
} |
||||
|
||||
// ListAccessTokenRoles enumerates authorized access token roles.
|
||||
func ListAccessTokenRoles(client *gophercloud.ServiceClient, userID string, id string) pagination.Pager { |
||||
url := userAccessTokenRolesURL(client, userID, id) |
||||
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { |
||||
return AccessTokenRolesPage{pagination.LinkedPageBase{PageResult: r}} |
||||
}) |
||||
} |
||||
|
||||
// GetAccessTokenRole retrieves details on a single OAuth1 access token role by
|
||||
// an ID.
|
||||
func GetAccessTokenRole(client *gophercloud.ServiceClient, userID string, id string, roleID string) (r GetAccessTokenRoleResult) { |
||||
resp, err := client.Get(userAccessTokenRoleURL(client, userID, id, roleID), &r.Body, nil) |
||||
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err) |
||||
return |
||||
} |
||||
|
||||
// The following are small helper functions used to help build the signature.
|
||||
|
||||
// buildOAuth1QueryString builds a URLEncoded parameters string specific for
|
||||
// OAuth1-based requests.
|
||||
func buildOAuth1QueryString(opts interface{}, timestamp *time.Time, callback string) (*url.URL, error) { |
||||
q, err := gophercloud.BuildQueryString(opts) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
query := q.Query() |
||||
|
||||
if timestamp != nil { |
||||
// use provided timestamp
|
||||
query.Set("oauth_timestamp", strconv.FormatInt(timestamp.Unix(), 10)) |
||||
} else { |
||||
// use current timestamp
|
||||
query.Set("oauth_timestamp", strconv.FormatInt(time.Now().UTC().Unix(), 10)) |
||||
} |
||||
|
||||
if query.Get("oauth_nonce") == "" { |
||||
// when nonce is not set, generate a random one
|
||||
query.Set("oauth_nonce", strconv.FormatInt(rand.Int63(), 10)+query.Get("oauth_timestamp")) |
||||
} |
||||
|
||||
if callback != "" { |
||||
query.Set("oauth_callback", callback) |
||||
} |
||||
query.Set("oauth_version", "1.0") |
||||
|
||||
return &url.URL{RawQuery: query.Encode()}, nil |
||||
} |
||||
|
||||
// buildStringToSign builds a string to be signed.
|
||||
func buildStringToSign(method string, u string, query url.Values) []byte { |
||||
parsedURL, _ := url.Parse(u) |
||||
p := parsedURL.Port() |
||||
s := parsedURL.Scheme |
||||
|
||||
// Default scheme port must be stripped
|
||||
if s == "http" && p == "80" || s == "https" && p == "443" { |
||||
parsedURL.Host = strings.TrimSuffix(parsedURL.Host, ":"+p) |
||||
} |
||||
|
||||
// Ensure that URL doesn't contain queries
|
||||
parsedURL.RawQuery = "" |
||||
|
||||
v := strings.Join( |
||||
[]string{method, url.QueryEscape(parsedURL.String()), url.QueryEscape(query.Encode())}, "&") |
||||
|
||||
return []byte(v) |
||||
} |
||||
|
||||
// signString signs a string using an OAuth1 signature method.
|
||||
func signString(signatureMethod SignatureMethod, strToSign []byte, signatureKeys []string) string { |
||||
var key []byte |
||||
for i, k := range signatureKeys { |
||||
key = append(key, []byte(url.QueryEscape(k))...) |
||||
if i == 0 { |
||||
key = append(key, '&') |
||||
} |
||||
} |
||||
|
||||
var signedString string |
||||
switch signatureMethod { |
||||
case PLAINTEXT: |
||||
signedString = string(key) |
||||
default: |
||||
h := hmac.New(sha1.New, key) |
||||
h.Write(strToSign) |
||||
signedString = base64.StdEncoding.EncodeToString(h.Sum(nil)) |
||||
} |
||||
|
||||
return signedString |
||||
} |
||||
|
||||
// buildAuthHeader generates an OAuth1 Authorization header with a signature
|
||||
// calculated using an OAuth1 signature method.
|
||||
func buildAuthHeader(query url.Values, signature string) string { |
||||
var authHeader []string |
||||
var keys []string |
||||
for k := range query { |
||||
keys = append(keys, k) |
||||
} |
||||
sort.Strings(keys) |
||||
|
||||
for _, k := range keys { |
||||
for _, v := range query[k] { |
||||
authHeader = append(authHeader, fmt.Sprintf("%s=%q", k, url.QueryEscape(v))) |
||||
} |
||||
} |
||||
|
||||
authHeader = append(authHeader, fmt.Sprintf("oauth_signature=%q", signature)) |
||||
|
||||
return "OAuth " + strings.Join(authHeader, ", ") |
||||
} |
||||
305
vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/results.go
generated
vendored
305
vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/results.go
generated
vendored
@ -0,0 +1,305 @@ |
||||
package oauth1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"net/url" |
||||
"time" |
||||
|
||||
"github.com/gophercloud/gophercloud" |
||||
"github.com/gophercloud/gophercloud/pagination" |
||||
) |
||||
|
||||
// Consumer represents a delegated authorization request between two
|
||||
// identities.
|
||||
type Consumer struct { |
||||
ID string `json:"id"` |
||||
Secret string `json:"secret"` |
||||
Description string `json:"description"` |
||||
} |
||||
|
||||
type consumerResult struct { |
||||
gophercloud.Result |
||||
} |
||||
|
||||
// CreateConsumerResult is the response from a Create operation. Call its
|
||||
// Extract method to interpret it as a Consumer.
|
||||
type CreateConsumerResult struct { |
||||
consumerResult |
||||
} |
||||
|
||||
// UpdateConsumerResult is the response from a Create operation. Call its
|
||||
// Extract method to interpret it as a Consumer.
|
||||
type UpdateConsumerResult struct { |
||||
consumerResult |
||||
} |
||||
|
||||
// DeleteConsumerResult is the response from a Delete operation. Call its
|
||||
// ExtractErr to determine if the request succeeded or failed.
|
||||
type DeleteConsumerResult struct { |
||||
gophercloud.ErrResult |
||||
} |
||||
|
||||
// ConsumersPage is a single page of Region results.
|
||||
type ConsumersPage struct { |
||||
pagination.LinkedPageBase |
||||
} |
||||
|
||||
// GetConsumerResult is the response from a Get operation. Call its Extract
|
||||
// method to interpret it as a Consumer.
|
||||
type GetConsumerResult struct { |
||||
consumerResult |
||||
} |
||||
|
||||
// IsEmpty determines whether or not a page of Consumers contains any results.
|
||||
func (c ConsumersPage) IsEmpty() (bool, error) { |
||||
consumers, err := ExtractConsumers(c) |
||||
return len(consumers) == 0, err |
||||
} |
||||
|
||||
// NextPageURL extracts the "next" link from the links section of the result.
|
||||
func (c ConsumersPage) NextPageURL() (string, error) { |
||||
var s struct { |
||||
Links struct { |
||||
Next string `json:"next"` |
||||
Previous string `json:"previous"` |
||||
} `json:"links"` |
||||
} |
||||
err := c.ExtractInto(&s) |
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
return s.Links.Next, err |
||||
} |
||||
|
||||
// ExtractConsumers returns a slice of Consumers contained in a single page of
|
||||
// results.
|
||||
func ExtractConsumers(r pagination.Page) ([]Consumer, error) { |
||||
var s struct { |
||||
Consumers []Consumer `json:"consumers"` |
||||
} |
||||
err := (r.(ConsumersPage)).ExtractInto(&s) |
||||
return s.Consumers, err |
||||
} |
||||
|
||||
// Extract interprets any consumer result as a Consumer.
|
||||
func (c consumerResult) Extract() (*Consumer, error) { |
||||
var s struct { |
||||
Consumer *Consumer `json:"consumer"` |
||||
} |
||||
err := c.ExtractInto(&s) |
||||
return s.Consumer, err |
||||
} |
||||
|
||||
// Token contains an OAuth1 token.
|
||||
type Token struct { |
||||
// OAuthToken is the key value for the oauth token that the Identity API returns.
|
||||
OAuthToken string `q:"oauth_token"` |
||||
// OAuthTokenSecret is the secret value associated with the OAuth Token.
|
||||
OAuthTokenSecret string `q:"oauth_token_secret"` |
||||
// OAUthExpiresAt is the date and time when an OAuth token expires.
|
||||
OAUthExpiresAt *time.Time `q:"-"` |
||||
} |
||||
|
||||
// TokenResult is a struct to handle
|
||||
// "Content-Type: application/x-www-form-urlencoded" response.
|
||||
type TokenResult struct { |
||||
gophercloud.Result |
||||
Body []byte |
||||
} |
||||
|
||||
// Extract interprets any OAuth1 token result as a Token.
|
||||
func (r TokenResult) Extract() (*Token, error) { |
||||
if r.Err != nil { |
||||
return nil, r.Err |
||||
} |
||||
|
||||
values, err := url.ParseQuery(string(r.Body)) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
token := &Token{ |
||||
OAuthToken: values.Get("oauth_token"), |
||||
OAuthTokenSecret: values.Get("oauth_token_secret"), |
||||
} |
||||
|
||||
if v := values.Get("oauth_expires_at"); v != "" { |
||||
if t, err := time.Parse(gophercloud.RFC3339Milli, v); err != nil { |
||||
return nil, err |
||||
} else { |
||||
token.OAUthExpiresAt = &t |
||||
} |
||||
} |
||||
|
||||
return token, nil |
||||
} |
||||
|
||||
// AuthorizedToken contains an OAuth1 authorized token info.
|
||||
type AuthorizedToken struct { |
||||
// OAuthVerifier is the ID of the token verifier.
|
||||
OAuthVerifier string `json:"oauth_verifier"` |
||||
} |
||||
|
||||
type AuthorizeTokenResult struct { |
||||
gophercloud.Result |
||||
} |
||||
|
||||
// Extract interprets AuthorizeTokenResult result as a AuthorizedToken.
|
||||
func (r AuthorizeTokenResult) Extract() (*AuthorizedToken, error) { |
||||
var s struct { |
||||
AuthorizedToken *AuthorizedToken `json:"token"` |
||||
} |
||||
err := r.ExtractInto(&s) |
||||
return s.AuthorizedToken, err |
||||
} |
||||
|
||||
// AccessToken represents an AccessToken response as a struct.
|
||||
type AccessToken struct { |
||||
ID string `json:"id"` |
||||
ConsumerID string `json:"consumer_id"` |
||||
ProjectID string `json:"project_id"` |
||||
AuthorizingUserID string `json:"authorizing_user_id"` |
||||
ExpiresAt *time.Time `json:"-"` |
||||
} |
||||
|
||||
func (r *AccessToken) UnmarshalJSON(b []byte) error { |
||||
type tmp AccessToken |
||||
var s struct { |
||||
tmp |
||||
ExpiresAt *gophercloud.JSONRFC3339Milli `json:"expires_at"` |
||||
} |
||||
err := json.Unmarshal(b, &s) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
*r = AccessToken(s.tmp) |
||||
|
||||
if s.ExpiresAt != nil { |
||||
t := time.Time(*s.ExpiresAt) |
||||
r.ExpiresAt = &t |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
type GetAccessTokenResult struct { |
||||
gophercloud.Result |
||||
} |
||||
|
||||
// Extract interprets any GetAccessTokenResult result as an AccessToken.
|
||||
func (r GetAccessTokenResult) Extract() (*AccessToken, error) { |
||||
var s struct { |
||||
AccessToken *AccessToken `json:"access_token"` |
||||
} |
||||
err := r.ExtractInto(&s) |
||||
return s.AccessToken, err |
||||
} |
||||
|
||||
// RevokeAccessTokenResult is the response from a Delete operation. Call its
|
||||
// ExtractErr to determine if the request succeeded or failed.
|
||||
type RevokeAccessTokenResult struct { |
||||
gophercloud.ErrResult |
||||
} |
||||
|
||||
// AccessTokensPage is a single page of Access Tokens results.
|
||||
type AccessTokensPage struct { |
||||
pagination.LinkedPageBase |
||||
} |
||||
|
||||
// IsEmpty determines whether or not a an AccessTokensPage contains any results.
|
||||
func (r AccessTokensPage) IsEmpty() (bool, error) { |
||||
accessTokens, err := ExtractAccessTokens(r) |
||||
return len(accessTokens) == 0, err |
||||
} |
||||
|
||||
// NextPageURL extracts the "next" link from the links section of the result.
|
||||
func (r AccessTokensPage) NextPageURL() (string, error) { |
||||
var s struct { |
||||
Links struct { |
||||
Next string `json:"next"` |
||||
Previous string `json:"previous"` |
||||
} `json:"links"` |
||||
} |
||||
err := r.ExtractInto(&s) |
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
return s.Links.Next, err |
||||
} |
||||
|
||||
// ExtractAccessTokens returns a slice of AccessTokens contained in a single
|
||||
// page of results.
|
||||
func ExtractAccessTokens(r pagination.Page) ([]AccessToken, error) { |
||||
var s struct { |
||||
AccessTokens []AccessToken `json:"access_tokens"` |
||||
} |
||||
err := (r.(AccessTokensPage)).ExtractInto(&s) |
||||
return s.AccessTokens, err |
||||
} |
||||
|
||||
// AccessTokenRole represents an Access Token Role struct.
|
||||
type AccessTokenRole struct { |
||||
ID string `json:"id"` |
||||
Name string `json:"name"` |
||||
DomainID string `json:"domain_id"` |
||||
} |
||||
|
||||
// AccessTokenRolesPage is a single page of Access Token roles results.
|
||||
type AccessTokenRolesPage struct { |
||||
pagination.LinkedPageBase |
||||
} |
||||
|
||||
// IsEmpty determines whether or not a an AccessTokensPage contains any results.
|
||||
func (r AccessTokenRolesPage) IsEmpty() (bool, error) { |
||||
accessTokenRoles, err := ExtractAccessTokenRoles(r) |
||||
return len(accessTokenRoles) == 0, err |
||||
} |
||||
|
||||
// NextPageURL extracts the "next" link from the links section of the result.
|
||||
func (r AccessTokenRolesPage) NextPageURL() (string, error) { |
||||
var s struct { |
||||
Links struct { |
||||
Next string `json:"next"` |
||||
Previous string `json:"previous"` |
||||
} `json:"links"` |
||||
} |
||||
err := r.ExtractInto(&s) |
||||
if err != nil { |
||||
return "", err |
||||
} |
||||
return s.Links.Next, err |
||||
} |
||||
|
||||
// ExtractAccessTokenRoles returns a slice of AccessTokenRole contained in a
|
||||
// single page of results.
|
||||
func ExtractAccessTokenRoles(r pagination.Page) ([]AccessTokenRole, error) { |
||||
var s struct { |
||||
AccessTokenRoles []AccessTokenRole `json:"roles"` |
||||
} |
||||
err := (r.(AccessTokenRolesPage)).ExtractInto(&s) |
||||
return s.AccessTokenRoles, err |
||||
} |
||||
|
||||
type GetAccessTokenRoleResult struct { |
||||
gophercloud.Result |
||||
} |
||||
|
||||
// Extract interprets any GetAccessTokenRoleResult result as an AccessTokenRole.
|
||||
func (r GetAccessTokenRoleResult) Extract() (*AccessTokenRole, error) { |
||||
var s struct { |
||||
AccessTokenRole *AccessTokenRole `json:"role"` |
||||
} |
||||
err := r.ExtractInto(&s) |
||||
return s.AccessTokenRole, err |
||||
} |
||||
|
||||
// OAuth1 is an OAuth1 object, returned in OAuth1 token result.
|
||||
type OAuth1 struct { |
||||
AccessTokenID string `json:"access_token_id"` |
||||
ConsumerID string `json:"consumer_id"` |
||||
} |
||||
|
||||
// TokenExt represents an extension of the base token result.
|
||||
type TokenExt struct { |
||||
OAuth1 OAuth1 `json:"OS-OAUTH1"` |
||||
} |
||||
@ -0,0 +1,43 @@ |
||||
package oauth1 |
||||
|
||||
import "github.com/gophercloud/gophercloud" |
||||
|
||||
func consumersURL(c *gophercloud.ServiceClient) string { |
||||
return c.ServiceURL("OS-OAUTH1", "consumers") |
||||
} |
||||
|
||||
func consumerURL(c *gophercloud.ServiceClient, id string) string { |
||||
return c.ServiceURL("OS-OAUTH1", "consumers", id) |
||||
} |
||||
|
||||
func requestTokenURL(c *gophercloud.ServiceClient) string { |
||||
return c.ServiceURL("OS-OAUTH1", "request_token") |
||||
} |
||||
|
||||
func authorizeTokenURL(c *gophercloud.ServiceClient, id string) string { |
||||
return c.ServiceURL("OS-OAUTH1", "authorize", id) |
||||
} |
||||
|
||||
func createAccessTokenURL(c *gophercloud.ServiceClient) string { |
||||
return c.ServiceURL("OS-OAUTH1", "access_token") |
||||
} |
||||
|
||||
func userAccessTokensURL(c *gophercloud.ServiceClient, userID string) string { |
||||
return c.ServiceURL("users", userID, "OS-OAUTH1", "access_tokens") |
||||
} |
||||
|
||||
func userAccessTokenURL(c *gophercloud.ServiceClient, userID string, id string) string { |
||||
return c.ServiceURL("users", userID, "OS-OAUTH1", "access_tokens", id) |
||||
} |
||||
|
||||
func userAccessTokenRolesURL(c *gophercloud.ServiceClient, userID string, id string) string { |
||||
return c.ServiceURL("users", userID, "OS-OAUTH1", "access_tokens", id, "roles") |
||||
} |
||||
|
||||
func userAccessTokenRoleURL(c *gophercloud.ServiceClient, userID string, id string, roleID string) string { |
||||
return c.ServiceURL("users", userID, "OS-OAUTH1", "access_tokens", id, "roles", roleID) |
||||
} |
||||
|
||||
func authURL(c *gophercloud.ServiceClient) string { |
||||
return c.ServiceURL("auth", "tokens") |
||||
} |
||||
22
vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/requests.go
generated
vendored
22
vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/requests.go
generated
vendored
@ -0,0 +1,8 @@ |
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library") |
||||
|
||||
go_library( |
||||
name = "go_default_library", |
||||
srcs = ["camel.go"], |
||||
importpath = "github.com/grpc-ecosystem/grpc-gateway/internal/casing", |
||||
visibility = ["//:__subpackages__"], |
||||
) |
||||
@ -0,0 +1,28 @@ |
||||
Copyright 2010 The Go Authors. All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are |
||||
met: |
||||
|
||||
* Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above |
||||
copyright notice, this list of conditions and the following disclaimer |
||||
in the documentation and/or other materials provided with the |
||||
distribution. |
||||
* Neither the name of Google Inc. nor the names of its |
||||
contributors may be used to endorse or promote products derived from |
||||
this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
@ -0,0 +1,5 @@ |
||||
# Case conversion |
||||
|
||||
This package contains a single function, copied from the |
||||
`github.com/golang/protobuf/protoc-gen-go/generator` package. That |
||||
modules LICENSE is referenced in its entirety in this package. |
||||
@ -0,0 +1,63 @@ |
||||
package casing |
||||
|
||||
// Camel returns the CamelCased name.
|
||||
//
|
||||
// This was moved from the now deprecated github.com/golang/protobuf/protoc-gen-go/generator package
|
||||
//
|
||||
// If there is an interior underscore followed by a lower case letter,
|
||||
// drop the underscore and convert the letter to upper case.
|
||||
// There is a remote possibility of this rewrite causing a name collision,
|
||||
// but it's so remote we're prepared to pretend it's nonexistent - since the
|
||||
// C++ generator lowercases names, it's extremely unlikely to have two fields
|
||||
// with different capitalizations.
|
||||
// In short, _my_field_name_2 becomes XMyFieldName_2.
|
||||
func Camel(s string) string { |
||||
if s == "" { |
||||
return "" |
||||
} |
||||
t := make([]byte, 0, 32) |
||||
i := 0 |
||||
if s[0] == '_' { |
||||
// Need a capital letter; drop the '_'.
|
||||
t = append(t, 'X') |
||||
i++ |
||||
} |
||||
// Invariant: if the next letter is lower case, it must be converted
|
||||
// to upper case.
|
||||
// That is, we process a word at a time, where words are marked by _ or
|
||||
// upper case letter. Digits are treated as words.
|
||||
for ; i < len(s); i++ { |
||||
c := s[i] |
||||
if c == '_' && i+1 < len(s) && isASCIILower(s[i+1]) { |
||||
continue // Skip the underscore in s.
|
||||
} |
||||
if isASCIIDigit(c) { |
||||
t = append(t, c) |
||||
continue |
||||
} |
||||
// Assume we have a letter now - if not, it's a bogus identifier.
|
||||
// The next word is a sequence of characters that must start upper case.
|
||||
if isASCIILower(c) { |
||||
c ^= ' ' // Make it a capital letter.
|
||||
} |
||||
t = append(t, c) // Guaranteed not lower case.
|
||||
// Accept lower case sequence that follows.
|
||||
for i+1 < len(s) && isASCIILower(s[i+1]) { |
||||
i++ |
||||
t = append(t, s[i]) |
||||
} |
||||
} |
||||
return string(t) |
||||
} |
||||
|
||||
// And now lots of helper functions.
|
||||
|
||||
// Is c an ASCII lower-case letter?
|
||||
func isASCIILower(c byte) bool { |
||||
return 'a' <= c && c <= 'z' |
||||
} |
||||
|
||||
// Is c an ASCII digit?
|
||||
func isASCIIDigit(c byte) bool { |
||||
return '0' <= c && c <= '9' |
||||
} |
||||
28
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/template.go
generated
vendored
28
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/template.go
generated
vendored
1
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/BUILD.bazel
generated
vendored
1
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/BUILD.bazel
generated
vendored
243
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.pb.go
generated
vendored
243
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.pb.go
generated
vendored
180
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.proto
generated
vendored
180
vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.proto
generated
vendored
@ -0,0 +1,30 @@ |
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package unsafeheader contains header declarations for the Go runtime's
|
||||
// slice and string implementations.
|
||||
//
|
||||
// This package allows x/sys to use types equivalent to
|
||||
// reflect.SliceHeader and reflect.StringHeader without introducing
|
||||
// a dependency on the (relatively heavy) "reflect" package.
|
||||
package unsafeheader |
||||
|
||||
import ( |
||||
"unsafe" |
||||
) |
||||
|
||||
// Slice is the runtime representation of a slice.
|
||||
// It cannot be used safely or portably and its representation may change in a later release.
|
||||
type Slice struct { |
||||
Data unsafe.Pointer |
||||
Len int |
||||
Cap int |
||||
} |
||||
|
||||
// String is the runtime representation of a string.
|
||||
// It cannot be used safely or portably and its representation may change in a later release.
|
||||
type String struct { |
||||
Data unsafe.Pointer |
||||
Len int |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue