Add centrify plugin as builtin
This commit is contained in:
parent
ffe3ae9118
commit
e5e4307713
|
@ -31,6 +31,7 @@ import (
|
|||
auditSocket "github.com/hashicorp/vault/builtin/audit/socket"
|
||||
auditSyslog "github.com/hashicorp/vault/builtin/audit/syslog"
|
||||
|
||||
credCentrify "github.com/hashicorp/vault-plugin-auth-centrify"
|
||||
credGcp "github.com/hashicorp/vault-plugin-auth-gcp/plugin"
|
||||
credKube "github.com/hashicorp/vault-plugin-auth-kubernetes"
|
||||
credAppId "github.com/hashicorp/vault/builtin/credential/app-id"
|
||||
|
@ -414,6 +415,7 @@ func init() {
|
|||
"app-id": credAppId.Factory,
|
||||
"approle": credAppRole.Factory,
|
||||
"aws": credAws.Factory,
|
||||
"centrify": credCentrify.Factory,
|
||||
"cert": credCert.Factory,
|
||||
"gcp": credGcp.Factory,
|
||||
"github": credGitHub.Factory,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
Copyright 2017 Centrify Corporation
|
||||
|
||||
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.
|
|
@ -0,0 +1,180 @@
|
|||
package oauth
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type HttpClientFactory func() *http.Client
|
||||
|
||||
// TokenResponse represents successful token response
|
||||
type TokenResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
Description string `json:"error_description"`
|
||||
}
|
||||
|
||||
// OauthClient represents a stateful Oauth client
|
||||
type OauthClient struct {
|
||||
Service string
|
||||
Client *http.Client
|
||||
Headers map[string]string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
SourceHeader string
|
||||
}
|
||||
|
||||
// GetNewClient creates a new client for the specified endpoint
|
||||
func GetNewClient(service string, httpFactory HttpClientFactory) (*OauthClient, error) {
|
||||
jar, err := cookiejar.New(nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Munge on the service a little bit, force it to have no trailing / and always start with https://
|
||||
var normalizedService = strings.TrimPrefix(service, "http://")
|
||||
normalizedService = strings.TrimPrefix(normalizedService, "https://")
|
||||
normalizedService = strings.TrimSuffix(normalizedService, "/")
|
||||
normalizedService = "https://" + normalizedService
|
||||
|
||||
client := &OauthClient{}
|
||||
client.Service = normalizedService
|
||||
if httpFactory != nil {
|
||||
client.Client = httpFactory()
|
||||
} else {
|
||||
client.Client = &http.Client{}
|
||||
}
|
||||
client.Client.Jar = jar
|
||||
client.Headers = make(map[string]string)
|
||||
client.SourceHeader = "cloud-golang-sdk"
|
||||
return client, err
|
||||
}
|
||||
|
||||
// GetNewConfidentialClient creates a new client for the specified endpoint
|
||||
func GetNewConfidentialClient(service string, clientID string, clientSecret string, httpFactory HttpClientFactory) (*OauthClient, error) {
|
||||
client, err := GetNewClient(service, httpFactory)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client.ClientID = clientID
|
||||
client.ClientSecret = clientSecret
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// ResourceOwner implements the ResourceOwner flow
|
||||
func (c *OauthClient) ResourceOwner(appID string, scope string, owner string, ownerPassword string) (*TokenResponse, *ErrorResponse, error) {
|
||||
args := make(map[string]string)
|
||||
args["grant_type"] = "password"
|
||||
args["username"] = owner
|
||||
args["password"] = ownerPassword
|
||||
args["scope"] = scope
|
||||
return c.postAndGetResponse("/oauth2/token/"+appID, args)
|
||||
}
|
||||
|
||||
func (c *OauthClient) ClientCredentials(appID string, scope string) (*TokenResponse, *ErrorResponse, error) {
|
||||
args := make(map[string]string)
|
||||
args["grant_type"] = "client_credentials"
|
||||
args["scope"] = scope
|
||||
return c.postAndGetResponse("/oauth2/token/"+appID, args)
|
||||
}
|
||||
|
||||
func (c *OauthClient) RefreshToken(appID string, refreshToken string) (*TokenResponse, *ErrorResponse, error) {
|
||||
args := make(map[string]string)
|
||||
args["grant_type"] = "refresh_token"
|
||||
args["refresh_token"] = refreshToken
|
||||
return c.postAndGetResponse("/oauth2/token/"+appID, args)
|
||||
}
|
||||
|
||||
func (c *OauthClient) postAndGetResponse(method string, args map[string]string) (*TokenResponse, *ErrorResponse, error) {
|
||||
body, status, err := c.postAndGetBody(method, args)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if status == 200 {
|
||||
response, err := bodyToTokenResponse(body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return response, nil, nil
|
||||
}
|
||||
|
||||
response, err := bodyToErrorResponse(body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return nil, response, nil
|
||||
}
|
||||
|
||||
func (c *OauthClient) postAndGetBody(method string, args map[string]string) ([]byte, int, error) {
|
||||
postdata := strings.NewReader(payloadFromMap(args))
|
||||
postreq, err := http.NewRequest("POST", c.Service+method, postdata)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if c.ClientID != "" && c.ClientSecret != "" {
|
||||
postreq.Header.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(c.ClientID+":"+c.ClientSecret)))
|
||||
}
|
||||
|
||||
postreq.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
postreq.Header.Add("X-CENTRIFY-NATIVE-CLIENT", "Yes")
|
||||
postreq.Header.Add("X-CFY-SRC", c.SourceHeader)
|
||||
|
||||
for k, v := range c.Headers {
|
||||
postreq.Header.Add(k, v)
|
||||
}
|
||||
|
||||
httpresp, err := c.Client.Do(postreq)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
defer httpresp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(httpresp.Body)
|
||||
if err != nil {
|
||||
return nil, httpresp.StatusCode, err
|
||||
}
|
||||
return body, httpresp.StatusCode, nil
|
||||
}
|
||||
|
||||
func payloadFromMap(input map[string]string) string {
|
||||
data := url.Values{}
|
||||
for i, v := range input {
|
||||
data.Add(i, v)
|
||||
}
|
||||
return data.Encode()
|
||||
}
|
||||
|
||||
func bodyToTokenResponse(body []byte) (*TokenResponse, error) {
|
||||
reply := &TokenResponse{}
|
||||
err := json.Unmarshal(body, &reply)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func bodyToErrorResponse(body []byte) (*ErrorResponse, error) {
|
||||
reply := &ErrorResponse{}
|
||||
err := json.Unmarshal(body, &reply)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return reply, nil
|
||||
}
|
|
@ -0,0 +1,191 @@
|
|||
package restapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type HttpClientFactory func() *http.Client
|
||||
|
||||
// BaseAPIResponse represents the most basic standard Centrify API response,
|
||||
// where Result itself is left as raw json
|
||||
type BaseAPIResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Result json.RawMessage
|
||||
Message string
|
||||
}
|
||||
|
||||
type StringResponse struct {
|
||||
BaseAPIResponse
|
||||
Result string
|
||||
}
|
||||
|
||||
type BoolResponse struct {
|
||||
BaseAPIResponse
|
||||
Result bool
|
||||
}
|
||||
|
||||
// GenericMapResponse represents Centrify API responses where results are map[string]interface{},
|
||||
// this type allows direct access to these without further decoding.
|
||||
type GenericMapResponse struct {
|
||||
BaseAPIResponse
|
||||
Result map[string]interface{}
|
||||
}
|
||||
|
||||
// BackendType is the type of backend that is being implemented
|
||||
type RestClientMode uint32
|
||||
|
||||
// RestClient represents a stateful API client (cookies maintained between calls, single service etc)
|
||||
type RestClient struct {
|
||||
Service string
|
||||
Client *http.Client
|
||||
Headers map[string]string
|
||||
SourceHeader string
|
||||
}
|
||||
|
||||
// GetNewRestClient creates a new RestClient for the specified endpoint. If a factory for creating
|
||||
// http.Client's is not provided, you'll get a new: &http.Client{}.
|
||||
func GetNewRestClient(service string, httpFactory HttpClientFactory) (*RestClient, error) {
|
||||
jar, err := cookiejar.New(nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Munge on the service a little bit, force it to have no trailing / and always start with https://
|
||||
var normalizedService = strings.TrimPrefix(service, "http://")
|
||||
normalizedService = strings.TrimPrefix(normalizedService, "https://")
|
||||
normalizedService = strings.TrimSuffix(normalizedService, "/")
|
||||
normalizedService = "https://" + normalizedService
|
||||
|
||||
client := &RestClient{}
|
||||
client.Service = normalizedService
|
||||
if httpFactory != nil {
|
||||
client.Client = httpFactory()
|
||||
} else {
|
||||
client.Client = &http.Client{}
|
||||
}
|
||||
client.Client.Jar = jar
|
||||
client.Headers = make(map[string]string)
|
||||
client.SourceHeader = "cloud-golang-sdk"
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (r *RestClient) CallRawAPI(method string, args map[string]interface{}) ([]byte, error) {
|
||||
return r.postAndGetBody(method, args)
|
||||
}
|
||||
|
||||
func (r *RestClient) CallBaseAPI(method string, args map[string]interface{}) (*BaseAPIResponse, error) {
|
||||
body, err := r.postAndGetBody(method, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bodyToBaseAPIResponse(body)
|
||||
}
|
||||
|
||||
func (r *RestClient) CallGenericMapAPI(method string, args map[string]interface{}) (*GenericMapResponse, error) {
|
||||
body, err := r.postAndGetBody(method, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bodyToGenericMapResponse(body)
|
||||
}
|
||||
|
||||
func (r *RestClient) CallStringAPI(method string, args map[string]interface{}) (*StringResponse, error) {
|
||||
body, err := r.postAndGetBody(method, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bodyToStringResponse(body)
|
||||
}
|
||||
|
||||
func (r *RestClient) CallBoolAPI(method string, args map[string]interface{}) (*BoolResponse, error) {
|
||||
body, err := r.postAndGetBody(method, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bodyToBoolResponse(body)
|
||||
}
|
||||
|
||||
func (r *RestClient) postAndGetBody(method string, args map[string]interface{}) ([]byte, error) {
|
||||
service := strings.TrimSuffix(r.Service, "/")
|
||||
method = strings.TrimPrefix(method, "/")
|
||||
postdata := strings.NewReader(payloadFromMap(args))
|
||||
postreq, err := http.NewRequest("POST", service+"/"+method, postdata)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
postreq.Header.Add("Content-Type", "application/json")
|
||||
postreq.Header.Add("X-CENTRIFY-NATIVE-CLIENT", "Yes")
|
||||
postreq.Header.Add("X-CFY-SRC", r.SourceHeader)
|
||||
|
||||
for k, v := range r.Headers {
|
||||
postreq.Header.Add(k, v)
|
||||
}
|
||||
|
||||
httpresp, err := r.Client.Do(postreq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer httpresp.Body.Close()
|
||||
|
||||
if httpresp.StatusCode == 200 {
|
||||
return ioutil.ReadAll(httpresp.Body)
|
||||
}
|
||||
|
||||
body, _ := ioutil.ReadAll(httpresp.Body)
|
||||
return nil, fmt.Errorf("POST to %s failed with code %d, body: %s", method, httpresp.StatusCode, body)
|
||||
}
|
||||
|
||||
// This function converts a map[string]interface{} into json string
|
||||
func payloadFromMap(input map[string]interface{}) string {
|
||||
if input != nil {
|
||||
p, _ := json.Marshal(input)
|
||||
return string(p)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func bodyToBaseAPIResponse(body []byte) (*BaseAPIResponse, error) {
|
||||
reply := &BaseAPIResponse{}
|
||||
err := json.Unmarshal(body, &reply)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to unmarshal BaseApiResponse from HTTP response: %v", err)
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func bodyToGenericMapResponse(body []byte) (*GenericMapResponse, error) {
|
||||
reply := &GenericMapResponse{}
|
||||
err := json.Unmarshal(body, &reply)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to unmarshal GenericMapResponse from HTTP response: %v", err)
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func bodyToStringResponse(body []byte) (*StringResponse, error) {
|
||||
reply := &StringResponse{}
|
||||
err := json.Unmarshal(body, &reply)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to unmarshal StringResponse from HTTP response: %v", err)
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func bodyToBoolResponse(body []byte) (*BoolResponse, error) {
|
||||
reply := &BoolResponse{}
|
||||
err := json.Unmarshal(body, &reply)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to unmarshal BoolResponse from HTTP response: %v", err)
|
||||
}
|
||||
return reply, nil
|
||||
}
|
297
vendor/github.com/hashicorp/vault-plugin-auth-centrify/Gopkg.lock
generated
vendored
Normal file
297
vendor/github.com/hashicorp/vault-plugin-auth-centrify/Gopkg.lock
generated
vendored
Normal file
|
@ -0,0 +1,297 @@
|
|||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/SermoDigital/jose"
|
||||
packages = [
|
||||
".",
|
||||
"crypto",
|
||||
"jws",
|
||||
"jwt"
|
||||
]
|
||||
revision = "f6df55f235c24f236d11dbcf665249a59ac2021f"
|
||||
version = "1.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/armon/go-radix"
|
||||
packages = ["."]
|
||||
revision = "1fca145dffbcaa8fe914309b1ec0cfc67500fe61"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/centrify/cloud-golang-sdk"
|
||||
packages = [
|
||||
"oauth",
|
||||
"restapi"
|
||||
]
|
||||
revision = "9067a9f81a511edbaa879586740e2b4ee79fd647"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/fatih/structs"
|
||||
packages = ["."]
|
||||
revision = "a720dfa8df582c51dee1b36feabb906bde1588bd"
|
||||
version = "v1.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = [
|
||||
"proto",
|
||||
"ptypes",
|
||||
"ptypes/any",
|
||||
"ptypes/duration",
|
||||
"ptypes/timestamp"
|
||||
]
|
||||
revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/golang/snappy"
|
||||
packages = ["."]
|
||||
revision = "553a641470496b2327abcac10b36396bd98e45c9"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/errwrap"
|
||||
packages = ["."]
|
||||
revision = "7554cd9344cec97297fa6649b055a8c98c2a1e55"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-cleanhttp"
|
||||
packages = ["."]
|
||||
revision = "d5fe4b57a186c716b0e00b8c301cbd9b4182694d"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-hclog"
|
||||
packages = ["."]
|
||||
revision = "ca137eb4b4389c9bc6f1a6d887f056bf16c00510"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-multierror"
|
||||
packages = ["."]
|
||||
revision = "b7773ae218740a7be65057fc60b366a49b538a44"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-plugin"
|
||||
packages = ["."]
|
||||
revision = "1fc09c47b843b73705f51ffb0520e3ac1bfecf99"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-rootcerts"
|
||||
packages = ["."]
|
||||
revision = "6bb64b370b90e7ef1fa532be9e591a81c3493e00"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-uuid"
|
||||
packages = ["."]
|
||||
revision = "64130c7a86d732268a38cb04cfbaf0cc987fda98"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/hcl"
|
||||
packages = [
|
||||
".",
|
||||
"hcl/ast",
|
||||
"hcl/parser",
|
||||
"hcl/scanner",
|
||||
"hcl/strconv",
|
||||
"hcl/token",
|
||||
"json/parser",
|
||||
"json/scanner",
|
||||
"json/token"
|
||||
]
|
||||
revision = "23c074d0eceb2b8a5bfdbb271ab780cde70f05a8"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/vault"
|
||||
packages = [
|
||||
"api",
|
||||
"helper/certutil",
|
||||
"helper/compressutil",
|
||||
"helper/consts",
|
||||
"helper/errutil",
|
||||
"helper/jsonutil",
|
||||
"helper/logbridge",
|
||||
"helper/logformat",
|
||||
"helper/mlock",
|
||||
"helper/parseutil",
|
||||
"helper/password",
|
||||
"helper/pluginutil",
|
||||
"helper/policyutil",
|
||||
"helper/salt",
|
||||
"helper/strutil",
|
||||
"helper/wrapping",
|
||||
"logical",
|
||||
"logical/framework",
|
||||
"logical/plugin",
|
||||
"logical/plugin/pb"
|
||||
]
|
||||
revision = "048a35d903f964376e04b3509a8817af5e712e2e"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/yamux"
|
||||
packages = ["."]
|
||||
revision = "683f49123a33db61abfb241b7ac5e4af4dc54d55"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-colorable"
|
||||
packages = ["."]
|
||||
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
|
||||
version = "v0.0.9"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||
version = "v0.0.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mgutz/ansi"
|
||||
packages = ["."]
|
||||
revision = "9520e82c474b0a04dd04f8a40959027271bab992"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mgutz/logxi"
|
||||
packages = ["v1"]
|
||||
revision = "aebf8a7d67ab4625e0fd4a665766fef9a709161b"
|
||||
version = "v1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/go-homedir"
|
||||
packages = ["."]
|
||||
revision = "b8bc1bf767474819792c23f32d8286a45736f1c6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/go-testing-interface"
|
||||
packages = ["."]
|
||||
revision = "a61a99592b77c9ba629d254a693acffaeb4b7e28"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/mapstructure"
|
||||
packages = ["."]
|
||||
revision = "b4575eea38cca1123ec2dc90c26529b5c5acfcff"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/oklog/run"
|
||||
packages = ["."]
|
||||
revision = "4dadeb3030eda0273a12382bb2348ffc7c9d1a39"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/ryanuber/go-glob"
|
||||
packages = ["."]
|
||||
revision = "572520ed46dbddaed19ea3d9541bdd0494163693"
|
||||
version = "v0.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sethgrid/pester"
|
||||
packages = ["."]
|
||||
revision = "760f8913c0483b776294e1bee43f1d687527127b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["ssh/terminal"]
|
||||
revision = "ee41a25c63fb5b74abf2213abb6dee3751e6ac4a"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
"http2",
|
||||
"http2/hpack",
|
||||
"idna",
|
||||
"internal/timeseries",
|
||||
"lex/httplex",
|
||||
"trace"
|
||||
]
|
||||
revision = "5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows"
|
||||
]
|
||||
revision = "2c42eef0765b9837fbdab12011af7830f55f88f0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/text"
|
||||
packages = [
|
||||
"collate",
|
||||
"collate/build",
|
||||
"internal/colltab",
|
||||
"internal/gen",
|
||||
"internal/tag",
|
||||
"internal/triegen",
|
||||
"internal/ucd",
|
||||
"language",
|
||||
"secure/bidirule",
|
||||
"transform",
|
||||
"unicode/bidi",
|
||||
"unicode/cldr",
|
||||
"unicode/norm",
|
||||
"unicode/rangetable"
|
||||
]
|
||||
revision = "e19ae1496984b1c655b8044a65c0300a3c878dd3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "google.golang.org/genproto"
|
||||
packages = ["googleapis/rpc/status"]
|
||||
revision = "a8101f21cf983e773d0c1133ebc5424792003214"
|
||||
|
||||
[[projects]]
|
||||
name = "google.golang.org/grpc"
|
||||
packages = [
|
||||
".",
|
||||
"balancer",
|
||||
"balancer/base",
|
||||
"balancer/roundrobin",
|
||||
"codes",
|
||||
"connectivity",
|
||||
"credentials",
|
||||
"encoding",
|
||||
"grpclb/grpc_lb_v1/messages",
|
||||
"grpclog",
|
||||
"health",
|
||||
"health/grpc_health_v1",
|
||||
"internal",
|
||||
"keepalive",
|
||||
"metadata",
|
||||
"naming",
|
||||
"peer",
|
||||
"resolver",
|
||||
"resolver/dns",
|
||||
"resolver/passthrough",
|
||||
"stats",
|
||||
"status",
|
||||
"tap",
|
||||
"transport"
|
||||
]
|
||||
revision = "7cea4cc846bcf00cbb27595b07da5de875ef7de9"
|
||||
version = "v1.9.1"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "2eff6761499c3523a5e35b28372261854d82ff51a6b5cc3aead2d373e7a2a7cd"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
|
@ -0,0 +1,37 @@
|
|||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/centrify/cloud-golang-sdk"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/hashicorp/go-cleanhttp"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/hashicorp/vault"
|
||||
branch = "master"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/mgutz/logxi"
|
||||
version = "1.0.0"
|
|
@ -0,0 +1,363 @@
|
|||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. "Contributor"
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the terms of
|
||||
a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
|
||||
means a work that combines Covered Software with other material, in a
|
||||
separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether
|
||||
at the time of the initial grant or subsequently, any and all of the
|
||||
rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the License,
|
||||
by the making, using, selling, offering for sale, having made, import,
|
||||
or transfer of either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, "control" means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights to
|
||||
grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter the
|
||||
recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty, or
|
||||
limitations of liability) contained within the Source Code Form of the
|
||||
Covered Software, except that You may alter any license notices to the
|
||||
extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute,
|
||||
judicial order, or regulation then You must: (a) comply with the terms of
|
||||
this License to the maximum extent possible; and (b) describe the
|
||||
limitations and the code they affect. Such description must be placed in a
|
||||
text file included with all distributions of the Covered Software under
|
||||
this License. Except to the extent prohibited by statute or regulation,
|
||||
such description must be sufficiently detailed for a recipient of ordinary
|
||||
skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing
|
||||
basis, if such Contributor fails to notify You of the non-compliance by
|
||||
some reasonable means prior to 60 days after You have come back into
|
||||
compliance. Moreover, Your grants from a particular Contributor are
|
||||
reinstated on an ongoing basis if such Contributor notifies You of the
|
||||
non-compliance by some reasonable means, this is the first time You have
|
||||
received notice of non-compliance with this License from such
|
||||
Contributor, and You become compliant prior to 30 days after Your receipt
|
||||
of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an "as is" basis,
|
||||
without warranty of any kind, either expressed, implied, or statutory,
|
||||
including, without limitation, warranties that the Covered Software is free
|
||||
of defects, merchantable, fit for a particular purpose or non-infringing.
|
||||
The entire risk as to the quality and performance of the Covered Software
|
||||
is with You. Should any Covered Software prove defective in any respect,
|
||||
You (not any Contributor) assume the cost of any necessary servicing,
|
||||
repair, or correction. This disclaimer of warranty constitutes an essential
|
||||
part of this License. No use of any Covered Software is authorized under
|
||||
this License except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from
|
||||
such party's negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
||||
incidental or consequential damages, so this exclusion and limitation may
|
||||
not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts
|
||||
of a jurisdiction where the defendant maintains its principal place of
|
||||
business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
||||
in this Section shall prevent a party's ability to bring cross-claims or
|
||||
counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides that
|
||||
the language of a contract shall be construed against the drafter shall not
|
||||
be used to construe this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses If You choose to distribute Source Code Form that is
|
||||
Incompatible With Secondary Licenses under the terms of this version of
|
||||
the License, the notice described in Exhibit B of this License must be
|
||||
attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file,
|
||||
then You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a
|
||||
notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
|
||||
This Source Code Form is "Incompatible
|
||||
With Secondary Licenses", as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
TOOL?=vault-plugin-auth-centrify
|
||||
TEST?=$$(go list ./... | grep -v /vendor/)
|
||||
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
|
||||
EXTERNAL_TOOLS=\
|
||||
github.com/mitchellh/gox \
|
||||
github.com/golang/dep/cmd/dep
|
||||
BUILD_TAGS?=${TOOL}
|
||||
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
|
||||
|
||||
# bin generates the releaseable binaries for this plugin
|
||||
bin: fmtcheck generate
|
||||
@CGO_ENABLED=0 BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
|
||||
|
||||
default: dev
|
||||
|
||||
# dev creates binaries for testing Vault locally. These are put
|
||||
# into ./bin/ as well as $GOPATH/bin, except for quickdev which
|
||||
# is only put into /bin/
|
||||
quickdev: generate
|
||||
@CGO_ENABLED=0 go build -i -tags='$(BUILD_TAGS)' -o bin/vault-plugin-auth-kubernetes
|
||||
dev: fmtcheck generate
|
||||
@CGO_ENABLED=0 BUILD_TAGS='$(BUILD_TAGS)' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'"
|
||||
dev-dynamic: generate
|
||||
@CGO_ENABLED=1 BUILD_TAGS='$(BUILD_TAGS)' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'"
|
||||
|
||||
# test runs the unit tests and vets the code
|
||||
test: fmtcheck generate
|
||||
CGO_ENABLED=0 VAULT_TOKEN= VAULT_ACC= go test -tags='$(BUILD_TAGS)' $(TEST) $(TESTARGS) -timeout=20m -parallel=4
|
||||
|
||||
testcompile: fmtcheck generate
|
||||
@for pkg in $(TEST) ; do \
|
||||
go test -v -c -tags='$(BUILD_TAGS)' $$pkg -parallel=4 ; \
|
||||
done
|
||||
|
||||
# testacc runs acceptance tests
|
||||
testacc: fmtcheck generate
|
||||
@if [ "$(TEST)" = "./..." ]; then \
|
||||
echo "ERROR: Set TEST to a specific package"; \
|
||||
exit 1; \
|
||||
fi
|
||||
VAULT_ACC=1 go test -tags='$(BUILD_TAGS)' $(TEST) -v $(TESTARGS) -timeout 45m
|
||||
|
||||
# generate runs `go generate` to build the dynamically generated
|
||||
# source files.
|
||||
generate:
|
||||
go generate $(go list ./... | grep -v /vendor/)
|
||||
|
||||
# bootstrap the build by downloading additional tools
|
||||
bootstrap:
|
||||
@for tool in $(EXTERNAL_TOOLS) ; do \
|
||||
echo "Installing/Updating $$tool" ; \
|
||||
go get -u $$tool; \
|
||||
done
|
||||
|
||||
fmtcheck:
|
||||
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
|
||||
|
||||
fmt:
|
||||
gofmt -w $(GOFMT_FILES)
|
||||
|
||||
|
||||
.PHONY: bin default generate test vet bootstrap fmt fmtcheck
|
|
@ -0,0 +1,165 @@
|
|||
# Vault Plugin: Centrify Identity Platform Auth Backend
|
||||
|
||||
This is a standalone backend plugin for use with [Hashicorp Vault](https://www.github.com/hashicorp/vault).
|
||||
This plugin allows for Centrify Identity Platform users accounts to authenticate with Vault.
|
||||
|
||||
**Please note**: We take Vault's security and our users' trust very seriously. If you believe you have found a security issue in Vault, _please responsibly disclose_ by contacting us at [security@hashicorp.com](mailto:security@hashicorp.com).
|
||||
|
||||
## Quick Links
|
||||
- Vault Website: https://www.vaultproject.io
|
||||
- Main Project Github: https://www.github.com/hashicorp/vault
|
||||
|
||||
## Getting Started
|
||||
|
||||
This is a [Vault plugin](https://www.vaultproject.io/docs/internals/plugins.html)
|
||||
and is meant to work with Vault. This guide assumes you have already installed Vault
|
||||
and have a basic understanding of how Vault works.
|
||||
|
||||
Otherwise, first read this guide on how to [get started with Vault](https://www.vaultproject.io/intro/getting-started/install.html).
|
||||
|
||||
To learn specifically about how plugins work, see documentation on [Vault plugins](https://www.vaultproject.io/docs/internals/plugins.html).
|
||||
|
||||
## Security Model
|
||||
|
||||
The current authentication model requires providing Vault with an OAuth2 Client ID and Secret, which can be used to make authenticated calls to the Centrify Identity Platform API. This token is scoped to allow only the required APIs for Vault integration, and cannot be used for interactive login directly.
|
||||
|
||||
## Usage
|
||||
|
||||
This plugin is currently built into Vault and by default is accessed
|
||||
at `auth/centrify`. To enable this in a running Vault server:
|
||||
|
||||
```sh
|
||||
$ vault auth-enable centrify
|
||||
Successfully enabled 'centrify' at 'centrify'!
|
||||
```
|
||||
|
||||
Before the plugin can authenticate users, both the plugin and your cloud service tenant must be configured correctly. To configure your cloud tenant, sign in as an administrator and perform the following actions. Please note that this plugin requires the Centrify Cloud Identity Service version 17.11 or newer.
|
||||
|
||||
### Create an OAuth2 Confidential Client
|
||||
|
||||
An OAuth2 Confidentical Client is a Centrify Directory User.
|
||||
|
||||
- Users -> Add User
|
||||
- Login Name: vault_integration@<yoursuffix>
|
||||
- Display Name: Vault Integration Confidential Client
|
||||
- Check the "Is OAuth confidentical client" box
|
||||
- Password Type: Generated (be sure to copy the value, you will need it later)
|
||||
- Create User
|
||||
|
||||
### Create a Role
|
||||
|
||||
To scope the users who can authenticate to vault, and to allow our Confidential Client access, we will create a role.
|
||||
|
||||
- Roles -> Add Role
|
||||
- Name: Vault Integration
|
||||
- Members -> Add
|
||||
- Search for and add the vault_integration@<yoursuffix> user
|
||||
- Additionally add any roles/groups/users who should be able to authenticate to vault
|
||||
- Save
|
||||
|
||||
### Create an OAuth2 Client Application
|
||||
- Apps -> Add Web Apps -> Custom -> OAuth2 Client
|
||||
- Configure the added application
|
||||
- Description:
|
||||
- Application ID: "vault_io_integration"
|
||||
- Application Name: "Vault Integration"
|
||||
- General Usage:
|
||||
- Client ID Type -> Confidential (must be OAuth client)
|
||||
- Tokens:
|
||||
- Token Type: JwtRS256
|
||||
- Auth methods: Client Creds + Resource Owner
|
||||
- Scope
|
||||
- Add a single scope named "vault_io_integration" with the following regexes:
|
||||
- usermgmt/getusersrolesandadministrativerights
|
||||
- security/whoami
|
||||
- User Access
|
||||
- Add the previously created "Vault Integration" role
|
||||
- Save
|
||||
|
||||
### Configuring the Vault Plugin
|
||||
|
||||
As an administrative vault user, you can read/write the centrify plugin configuration using the /auth/centrify/config path:
|
||||
|
||||
```sh
|
||||
$ vault write auth/centrify/config service_url=https://<tenantid>.my.centrify.com client_id=vault_integration@<yoursuffix> client_secret=<password copied earlier> app_id=vault_io_integration scope=vault_io_integration
|
||||
```
|
||||
|
||||
### Authenticating
|
||||
|
||||
As a valid user of your tenant, in the appropriate role for accessing the Vault Integration app, you can now authenticate to the vault:
|
||||
|
||||
```sh
|
||||
$ vault auth -method=centrify username=<your username>
|
||||
```
|
||||
|
||||
Your vault token will be valid for the length of time defined in the app's token lifetime configuration (default 5 hours).
|
||||
|
||||
## Developing
|
||||
|
||||
If you wish to work on this plugin, you'll first need
|
||||
[Go](https://www.golang.org) installed on your machine
|
||||
(version 1.9+ is *required*).
|
||||
|
||||
For local dev first make sure Go is properly installed, including
|
||||
setting up a [GOPATH](https://golang.org/doc/code.html#GOPATH).
|
||||
Next, clone this repository into
|
||||
`$GOPATH/src/github.com/hashicorp/vault-plugin-auth-centrify`.
|
||||
You can then download any required build tools by bootstrapping your
|
||||
environment:
|
||||
|
||||
```sh
|
||||
$ make bootstrap
|
||||
```
|
||||
|
||||
To compile a development version of this plugin, run `make` or `make dev`.
|
||||
This will put the plugin binary in the `bin` and `$GOPATH/bin` folders. `dev`
|
||||
mode will only generate the binary for your platform and is faster:
|
||||
|
||||
```sh
|
||||
$ make
|
||||
$ make dev
|
||||
```
|
||||
|
||||
Put the plugin binary into a location of your choice. This directory
|
||||
will be specified as the [`plugin_directory`](https://www.vaultproject.io/docs/configuration/index.html#plugin_directory)
|
||||
in the Vault config used to start the server.
|
||||
|
||||
```json
|
||||
...
|
||||
plugin_directory = "path/to/plugin/directory"
|
||||
...
|
||||
```
|
||||
|
||||
Start a Vault server with this config file:
|
||||
```sh
|
||||
$ vault server -config=path/to/config.json ...
|
||||
...
|
||||
```
|
||||
|
||||
Once the server is started, register the plugin in the Vault server's [plugin catalog](https://www.vaultproject.io/docs/internals/plugins.html#plugin-catalog):
|
||||
|
||||
```sh
|
||||
$ vault write sys/plugins/catalog/centrify \
|
||||
sha_256=<expected SHA256 Hex value of the plugin binary> \
|
||||
command="vault-plugin-auth-centrify"
|
||||
...
|
||||
Success! Data written to: sys/plugins/catalog/centrify
|
||||
```
|
||||
|
||||
Note you should generate a new sha256 checksum if you have made changes
|
||||
to the plugin. Example using openssl:
|
||||
|
||||
```sh
|
||||
openssl dgst -sha256 $GOPATH/vault-plugin-auth-centrify
|
||||
...
|
||||
SHA256(.../go/bin/vault-plugin-auth-centrify)= 896c13c0f5305daed381952a128322e02bc28a57d0c862a78cbc2ea66e8c6fa1
|
||||
```
|
||||
|
||||
Enable the auth plugin backend using the Centrify auth plugin:
|
||||
|
||||
```sh
|
||||
$ vault auth-enable -plugin-name='centrify' plugin
|
||||
...
|
||||
|
||||
Successfully enabled 'plugin' at 'centrify'!
|
||||
```
|
|
@ -0,0 +1,52 @@
|
|||
package centrify
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
)
|
||||
|
||||
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
|
||||
b := Backend()
|
||||
if err := b.Setup(ctx, conf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func Backend() *backend {
|
||||
var b backend
|
||||
|
||||
b.Backend = &framework.Backend{
|
||||
Help: backendHelp,
|
||||
|
||||
PathsSpecial: &logical.Paths{
|
||||
Unauthenticated: []string{
|
||||
"login",
|
||||
},
|
||||
SealWrapStorage: []string{
|
||||
"config",
|
||||
},
|
||||
},
|
||||
|
||||
Paths: []*framework.Path{
|
||||
pathConfig(&b),
|
||||
pathLogin(&b),
|
||||
},
|
||||
|
||||
BackendType: logical.TypeCredential,
|
||||
}
|
||||
|
||||
return &b
|
||||
}
|
||||
|
||||
type backend struct {
|
||||
*framework.Backend
|
||||
}
|
||||
|
||||
const backendHelp = `
|
||||
The "centrify" credential provider allows authentication using
|
||||
a combination of a username and password via the Centrify Identity
|
||||
Services Platform.
|
||||
`
|
|
@ -0,0 +1,66 @@
|
|||
package centrify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
pwd "github.com/hashicorp/vault/helper/password"
|
||||
)
|
||||
|
||||
type CLIHandler struct{}
|
||||
|
||||
func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, error) {
|
||||
mount, ok := m["mount"]
|
||||
if !ok {
|
||||
mount = "centrify"
|
||||
}
|
||||
|
||||
username, ok := m["username"]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("'username' not supplied")
|
||||
}
|
||||
|
||||
password, ok := m["password"]
|
||||
if !ok {
|
||||
fmt.Printf("Password (will be hidden): ")
|
||||
var err error
|
||||
password, err = pwd.Read(os.Stdin)
|
||||
fmt.Println()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"username": username,
|
||||
"password": password,
|
||||
}
|
||||
|
||||
mode, ok := m["mode"]
|
||||
if ok {
|
||||
data["mode"] = mode
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("auth/%s/login", mount)
|
||||
secret, err := c.Logical().Write(path, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if secret == nil {
|
||||
return nil, fmt.Errorf("empty response from credential provider")
|
||||
}
|
||||
|
||||
return secret, nil
|
||||
}
|
||||
|
||||
func (h *CLIHandler) Help() string {
|
||||
help := `
|
||||
The "centrify" credential provider allows you to authenticate with
|
||||
a username and password. To use it, specify the "username" and "password"
|
||||
parameters. If password is not provided on the command line, it will be
|
||||
read from stdin.`
|
||||
|
||||
return strings.TrimSpace(help)
|
||||
}
|
209
vendor/github.com/hashicorp/vault-plugin-auth-centrify/path_config.go
generated
vendored
Normal file
209
vendor/github.com/hashicorp/vault-plugin-auth-centrify/path_config.go
generated
vendored
Normal file
|
@ -0,0 +1,209 @@
|
|||
package centrify
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/hashicorp/vault/helper/policyutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
)
|
||||
|
||||
func pathConfig(b *backend) *framework.Path {
|
||||
return &framework.Path{
|
||||
Pattern: "config",
|
||||
Fields: map[string]*framework.FieldSchema{
|
||||
"client_id": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "OAuth2 Client ID",
|
||||
},
|
||||
"client_secret": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "OAuth2 Client Secret",
|
||||
},
|
||||
"service_url": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "Service URL (https://<tenant>.my.centrify.com)",
|
||||
},
|
||||
"app_id": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "OAuth2 App ID",
|
||||
Default: "vault_io_integration",
|
||||
},
|
||||
"scope": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "OAuth2 App Scope",
|
||||
Default: "vault_io_integration",
|
||||
},
|
||||
"policies": &framework.FieldSchema{
|
||||
Type: framework.TypeCommaStringSlice,
|
||||
Description: "Comma-separated list of policies all authenticated users inherit",
|
||||
},
|
||||
},
|
||||
|
||||
ExistenceCheck: b.pathConfigExistCheck,
|
||||
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.UpdateOperation: b.pathConfigCreateOrUpdate,
|
||||
logical.CreateOperation: b.pathConfigCreateOrUpdate,
|
||||
logical.ReadOperation: b.pathConfigRead,
|
||||
},
|
||||
|
||||
HelpSynopsis: pathSyn,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *backend) pathConfigExistCheck(ctx context.Context, req *logical.Request, data *framework.FieldData) (bool, error) {
|
||||
config, err := b.Config(ctx, req.Storage)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (b *backend) pathConfigCreateOrUpdate(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
cfg, err := b.Config(ctx, req.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if cfg == nil {
|
||||
cfg = &config{}
|
||||
}
|
||||
|
||||
val, ok := data.GetOk("client_id")
|
||||
if ok {
|
||||
cfg.ClientID = val.(string)
|
||||
} else if req.Operation == logical.CreateOperation {
|
||||
cfg.ClientID = data.Get("client_id").(string)
|
||||
}
|
||||
if cfg.ClientID == "" {
|
||||
return logical.ErrorResponse("config parameter `client_id` cannot be empty"), nil
|
||||
}
|
||||
|
||||
val, ok = data.GetOk("client_secret")
|
||||
if ok {
|
||||
cfg.ClientSecret = val.(string)
|
||||
} else if req.Operation == logical.CreateOperation {
|
||||
cfg.ClientSecret = data.Get("client_secret").(string)
|
||||
}
|
||||
if cfg.ClientSecret == "" {
|
||||
return logical.ErrorResponse("config parameter `client_secret` cannot be empty"), nil
|
||||
}
|
||||
|
||||
val, ok = data.GetOk("service_url")
|
||||
if ok {
|
||||
cfg.ServiceURL = val.(string)
|
||||
} else if req.Operation == logical.CreateOperation {
|
||||
cfg.ServiceURL = data.Get("service_url").(string)
|
||||
}
|
||||
if cfg.ServiceURL == "" {
|
||||
return logical.ErrorResponse("config parameter `service_url` cannot be empty"), nil
|
||||
}
|
||||
|
||||
val, ok = data.GetOk("app_id")
|
||||
if ok {
|
||||
cfg.AppID = val.(string)
|
||||
} else if req.Operation == logical.CreateOperation {
|
||||
cfg.AppID = data.Get("app_id").(string)
|
||||
}
|
||||
|
||||
val, ok = data.GetOk("scope")
|
||||
if ok {
|
||||
cfg.Scope = val.(string)
|
||||
} else if req.Operation == logical.CreateOperation {
|
||||
cfg.Scope = data.Get("scope").(string)
|
||||
}
|
||||
|
||||
val, ok = data.GetOk("policies")
|
||||
if ok {
|
||||
cfg.Policies = policyutil.ParsePolicies(val)
|
||||
} else if req.Operation == logical.CreateOperation {
|
||||
cfg.Policies = policyutil.ParsePolicies(data.Get("policies"))
|
||||
}
|
||||
|
||||
// We want to normalize the service url to https://
|
||||
url, err := url.Parse(cfg.ServiceURL)
|
||||
if err != nil {
|
||||
return logical.ErrorResponse(fmt.Sprintf("config parameter 'service_url' is not a valid url: %s", err)), nil
|
||||
}
|
||||
|
||||
// Its a proper url, just force the scheme to https, and strip any paths
|
||||
url.Scheme = "https"
|
||||
url.Path = ""
|
||||
cfg.ServiceURL = url.String()
|
||||
|
||||
entry, err := logical.StorageEntryJSON("config", cfg)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := req.Storage.Put(ctx, entry); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *backend) pathConfigRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
config, err := b.Config(ctx, req.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
resp := &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"client_id": config.ClientID,
|
||||
"client_secret": config.ClientSecret,
|
||||
"service_url": config.ServiceURL,
|
||||
"app_id": config.AppID,
|
||||
"scope": config.Scope,
|
||||
"policies": config.Policies,
|
||||
},
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Config returns the configuration for this backend.
|
||||
func (b *backend) Config(ctx context.Context, s logical.Storage) (*config, error) {
|
||||
entry, err := s.Get(ctx, "config")
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result config
|
||||
if entry != nil {
|
||||
if err := entry.DecodeJSON(&result); err != nil {
|
||||
return nil, fmt.Errorf("error reading configuration: %s", err)
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type config struct {
|
||||
ClientID string `json:"client_id"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
ServiceURL string `json:"service_url"`
|
||||
AppID string `json:"app_id"`
|
||||
Scope string `json:"scope"`
|
||||
Policies []string `json:"policies"`
|
||||
}
|
||||
|
||||
const pathSyn = `
|
||||
This path allows you to configure the centrify auth provider to interact with the Centrify Identity Services Platform
|
||||
for authenticating users.
|
||||
`
|
201
vendor/github.com/hashicorp/vault-plugin-auth-centrify/path_login.go
generated
vendored
Normal file
201
vendor/github.com/hashicorp/vault-plugin-auth-centrify/path_login.go
generated
vendored
Normal file
|
@ -0,0 +1,201 @@
|
|||
package centrify
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-cleanhttp"
|
||||
|
||||
"github.com/centrify/cloud-golang-sdk/oauth"
|
||||
"github.com/centrify/cloud-golang-sdk/restapi"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
)
|
||||
|
||||
const sourceHeader string = "vault-plugin-auth-centrify"
|
||||
|
||||
func pathLogin(b *backend) *framework.Path {
|
||||
return &framework.Path{
|
||||
Pattern: "login",
|
||||
Fields: map[string]*framework.FieldSchema{
|
||||
"username": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "Username of the user.",
|
||||
},
|
||||
"password": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "Password for this user.",
|
||||
},
|
||||
"mode": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "Auth mode ('ro' for resource owner, 'cc' for credential client).",
|
||||
Default: "ro",
|
||||
},
|
||||
},
|
||||
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.UpdateOperation: b.pathLogin,
|
||||
logical.AliasLookaheadOperation: b.pathLoginAliasLookahead,
|
||||
},
|
||||
|
||||
HelpSynopsis: pathLoginSyn,
|
||||
HelpDescription: pathLoginDesc,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *backend) pathLoginAliasLookahead(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||
username := strings.ToLower(d.Get("username").(string))
|
||||
if username == "" {
|
||||
return nil, fmt.Errorf("missing username")
|
||||
}
|
||||
|
||||
return &logical.Response{
|
||||
Auth: &logical.Auth{
|
||||
Alias: &logical.Alias{
|
||||
Name: username,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||
username := strings.ToLower(d.Get("username").(string))
|
||||
password := d.Get("password").(string)
|
||||
mode := d.Get("mode").(string)
|
||||
|
||||
if password == "" {
|
||||
return nil, fmt.Errorf("missing password")
|
||||
}
|
||||
|
||||
config, err := b.Config(ctx, req.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
return nil, errors.New("centrify auth plugin configuration not set")
|
||||
}
|
||||
|
||||
var token *oauth.TokenResponse
|
||||
var failure *oauth.ErrorResponse
|
||||
|
||||
switch mode {
|
||||
case "cc":
|
||||
oclient, err := oauth.GetNewConfidentialClient(config.ServiceURL, username, password, cleanhttp.DefaultClient)
|
||||
oclient.SourceHeader = sourceHeader
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
token, failure, err = oclient.ClientCredentials(config.AppID, config.Scope)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "ro":
|
||||
oclient, err := oauth.GetNewConfidentialClient(config.ServiceURL, config.ClientID, config.ClientSecret, cleanhttp.DefaultClient)
|
||||
oclient.SourceHeader = sourceHeader
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
token, failure, err = oclient.ResourceOwner(config.AppID, config.Scope, username, password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid mode or no mode provided: %s", mode)
|
||||
}
|
||||
|
||||
if failure != nil {
|
||||
return nil, fmt.Errorf("OAuth2 token request failed: %v", failure)
|
||||
}
|
||||
|
||||
uinfo, err := b.getUserInfo(token, config.ServiceURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.Logger().Trace("centrify authenticated user", "userinfo", uinfo)
|
||||
|
||||
resp := &logical.Response{
|
||||
Auth: &logical.Auth{
|
||||
Policies: config.Policies,
|
||||
Metadata: map[string]string{
|
||||
"username": uinfo.username,
|
||||
},
|
||||
DisplayName: username,
|
||||
LeaseOptions: logical.LeaseOptions{
|
||||
TTL: time.Duration(token.ExpiresIn) * time.Second,
|
||||
Renewable: false,
|
||||
},
|
||||
Alias: &logical.Alias{
|
||||
Name: username,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, role := range uinfo.roles {
|
||||
resp.Auth.GroupAliases = append(resp.Auth.GroupAliases, &logical.Alias{
|
||||
Name: role,
|
||||
})
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type userinfo struct {
|
||||
uuid string
|
||||
username string
|
||||
roles []string
|
||||
}
|
||||
|
||||
// getUserInfo returns list of user's roles, user uuid, user name
|
||||
func (b *backend) getUserInfo(accessToken *oauth.TokenResponse, serviceUrl string) (*userinfo, error) {
|
||||
uinfo := &userinfo{}
|
||||
|
||||
restClient, err := restapi.GetNewRestClient(serviceUrl, cleanhttp.DefaultClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
restClient.Headers["Authorization"] = accessToken.TokenType + " " + accessToken.AccessToken
|
||||
restClient.SourceHeader = sourceHeader
|
||||
|
||||
// First call /security/whoami to get details on current user
|
||||
whoami, err := restClient.CallGenericMapAPI("/security/whoami", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
uinfo.username = whoami.Result["User"].(string)
|
||||
uinfo.uuid = whoami.Result["UserUuid"].(string)
|
||||
|
||||
// Now enumerate roles
|
||||
rolesAndRightsResult, err := restClient.CallGenericMapAPI("/usermgmt/GetUsersRolesAndAdministrativeRights", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uinfo.roles = make([]string, 0)
|
||||
|
||||
if rolesAndRightsResult.Success {
|
||||
// Results is an array of map[string]interface{}
|
||||
var results = rolesAndRightsResult.Result["Results"].([]interface{})
|
||||
for _, v := range results {
|
||||
var resultItem = v.(map[string]interface{})
|
||||
var row = resultItem["Row"].(map[string]interface{})
|
||||
uinfo.roles = append(uinfo.roles, row["Name"].(string))
|
||||
}
|
||||
} else {
|
||||
b.Logger().Error("centrify: failed to get user roles", "error", rolesAndRightsResult.Message)
|
||||
}
|
||||
|
||||
return uinfo, nil
|
||||
}
|
||||
|
||||
const pathLoginSyn = `
|
||||
Log in with a username and password.
|
||||
`
|
||||
|
||||
const pathLoginDesc = `
|
||||
This endpoint authenticates using a username and password against the Centrify Identity Services Platform.
|
||||
`
|
|
@ -450,6 +450,18 @@
|
|||
"revision": "309aa717adbf351e92864cbedf9cca0b769a4b5a",
|
||||
"revisionTime": "2017-10-07T11:45:50Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "K8OA7Gq9EDgWN52jOkWFI84CHAE=",
|
||||
"path": "github.com/centrify/cloud-golang-sdk/oauth",
|
||||
"revision": "9067a9f81a511edbaa879586740e2b4ee79fd647",
|
||||
"revisionTime": "2017-12-06T22:18:58Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "hQuaxxdKR13A1/LOAQeb9wFGXI0=",
|
||||
"path": "github.com/centrify/cloud-golang-sdk/restapi",
|
||||
"revision": "9067a9f81a511edbaa879586740e2b4ee79fd647",
|
||||
"revisionTime": "2017-12-06T22:18:58Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "sFjc2R+KS9AeXIPMV4KCw+GwX5I=",
|
||||
"path": "github.com/chrismalek/oktasdk-go/okta",
|
||||
|
@ -1152,6 +1164,12 @@
|
|||
"revision": "c20a0b1b1ea9eb8168bcdec0116688fa9254e449",
|
||||
"revisionTime": "2017-10-22T02:00:50Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "79lZZZCBawKk80SjL1toOFKxU9M=",
|
||||
"path": "github.com/hashicorp/vault-plugin-auth-centrify",
|
||||
"revision": "8091c91cd9df635c07bce4d31d123ca3a89c24aa",
|
||||
"revisionTime": "2018-01-19T10:58:34Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "eVlMWanJ2W+/9c1kz72iefRcrYM=",
|
||||
"path": "github.com/hashicorp/vault-plugin-auth-gcp/plugin",
|
||||
|
|
Loading…
Reference in New Issue