Coder Social home page Coder Social logo

go-uaa's Introduction

go-uaa Travis-CI godoc Report card

Overview

go-uaa is a client library for the UAA API. It is a go module.

Usage

Step 1: Add go-uaa As A Dependency

$ go mod init # optional
$ go get -u github.com/cloudfoundry-community/go-uaa
$ cat go.mod
module github.com/cloudfoundry-community/go-uaa/cmd/test

go 1.13

require github.com/cloudfoundry-community/go-uaa latest

Step 2: Construct and Use uaa.API

Construct a uaa.API by using uaa.New(target string, authOpt AuthenticationOption, opts ...Option):

$ cat main.go
package main

import (
	"log"

	uaa "github.com/cloudfoundry-community/go-uaa"
)

func main() {
	// construct the API
	api, err := uaa.New(
		"https://uaa.example.net",
		uaa.WithClientCredentials("client-id", "client-secret", uaa.JSONWebToken),
	)
	if err != nil {
		log.Fatal(err)
	}

	// use the API to fetch a user
	user, err := api.GetUserByUsername("[email protected]", "uaa", "")
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Hello, %s\n", user.Name.GivenName)
}

Experimental

  • For the foreseeable future, releases will be in the v0.x.y range
  • You should expect breaking changes until v1.x.y releases occur
  • Notifications of breaking changes will be made via release notes associated with each tag
  • You should use go modules with this package

Contributing

Pull requests welcome.

go-uaa's People

Contributors

ablease avatar andrewedstrom avatar birdrock avatar dennisdenuto avatar dependabot-preview[bot] avatar dependabot[bot] avatar dray56 avatar drnic avatar dsabeti avatar jhamon avatar jmcarp avatar joefitzgerald avatar jpalermo avatar mirahimage avatar norman-abramovitz avatar shamus avatar smitt04 avatar strehle avatar wjjackson7 avatar wjun avatar zmb3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-uaa's Issues

issue with special character in client secret

go-uaa uses oauth2 from standard go and this encodes authorization header according to standard
RFC, see
https://github.com/golang/oauth2/blob/master/internal/token.go#L195

However UAA as backend server does not handle this encoding, see existing issue on
cloudfoundry/uaa#778

I would like to have a direction for a fix, means, use non RFC complient encoding in go-uaa (uaa-cli) or fix UAA .
Problem now it, that uaa-cli (client) and uaa (server) are not working together if special characters in secret

e.g.
client_id: admin
client_secret: admin#secret

Unable to Update User due to missing 'If-Match' Header

According to the docs, updating a user requires the 'If-Match' Header. But according to the current implementation, this header is not being added and therefore update user is failing.

{"error_description":"Missing If-Match for PUT","error":"scim","message":"Missing If-Match for PUT"}

Solution would be to add this header for the put calls for users and groups

AuthenticatedClient objects created too soon

Consider https://github.com/cloudfoundry-community/go-uaa/blob/377005ac1e67d387c4e4ba66000fd3f2f35bda8b/api.go#L145-L148

The AuthenticatedClient object is built with client := &http.Client{Transport: http.DefaultTransport}, and so does not allow an opportunity for the caller of NewWithPasswordCredentials to setup an alternate client (say with custom root CAs).

Perhaps AuthenticatedClient and UnauthenticatedClient() should be functions that are built as needed using ContextClient()?

For similar reasons, perhaps we do away with API.SkipSSLValidation and instead encourage construction of explicit clients? e.g.:

tr := &http.Transport{
	TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
api.UnauthenticatedClient = &http.Client{Transport: tr}
me, err := api.GetMe()

Or

rootCAs, _ := x509.SystemCertPool()
if rootCAs == nil {
	rootCAs = x509.NewCertPool()
}
rootCAs.AppendCertsFromPEM([]byte(opts.UAACACert))
tr := &http.Transport{
	TLSClientConfig: &tls.Config{
		RootCAs: rootCAs,
	},
}
api.UnauthenticatedClient = &http.Client{Transport: tr}

Curl non-UAA hosts w/UAA context

See cloudfoundry/uaa-cli#62

Assuming this should be implemented it seems like go-uaa's curl function should support external hosts versus duplicating a bunch of the transport logic in the CLI.

This Curl function could be backwards compatible based off if the passed in url contains a host.

Curl does not respect SkipSSLValidation

Tracking issue - PR incoming.

API.Curl uses the AuthenticatedClient directly and is missing a call to ensureTransport, so it is not possible to curl a UAA with a self signed certificate.

Cross Scripting Security Vulnerability - Checkmarx

Checkmarx Security scan has caught a high priority security vulnerability in uaa_transport.go

From the report:
The application's func embeds untrusted data in the generated output with Printf, at line 42 of
server/uaa/uaa_transport.go. This untrusted data is embedded straight into the output without proper sanitization or
encoding, enabling an attacker to inject malicious code into the output.
The attacker would be able to alter the output data by simply sending modified values in the user input Header, which is
read by the func method at line 15 of server/uaa/uaa_transport.go. This input then flows through the code, and written to
the console or STDOUT, without sanitization. In some scenarios, this output will also be sent back to the user's browser.
This can enable a Reflected Cross-Site Scripting (XSS) attack if the code's console output is used by the application as
part of a web-page, as often occurs with CGI scripts.

What is the proper way to sanitize this logging printf?

Creating a client with "implicit" authorized_grant_types FAILS

Hello,
When I try to create a client with "authorized_grant_types":["implicit"] the command fails, but if I change the authorized_grant_types to be client_credentials the command is successful. If I create the client with client_credentials and then replace the value with implicit - everything is ok. Can someone please help fixing this? We are using the latest version of the go-uaa client

provide responseCode and response body along with error from "doAndRead" method

I am using go-uaa module to make uaa calls, but the calls like
GetClient, GetUser, CreateClient gives out generic error message "return errors.Errorf("An error occurred while calling %s", url)". This message is not enough to write code to react to it.
For example in my code to delete a "client" I want to inform the user that the "client" you are trying to delete does not exist, and not error out :).
But this is not possible if I do not know what is the returned response from UAA which is hidden by UAA Client in not so nice way.

New release?

Hi,

Is it possible to release new version of go-uaa. When we vendor this package only latest release version is getting pulled. We would like some latest changes since the last release.

How to store AccessToken/RefreshToken/TokenType?

If my CLI captures the username/password from a user, and then use uaa.NewWithPasswordCredentials(..) to construct my uaa.API, how do I get the AccessToken/RefreshToken/TokenType from uaa.API so I can store it locally for later use (subsequent CLI commands) without needing to cache the username/password?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.