Git Product home page Git Product logo

goat's Introduction

Goat Build Status Coverage Status

THIS LIBRARY IS NO LONGER MAINTAINED

What is Goat?

Goat is a golang SDK for auth0 API.

It tries to answer the lack of SDK in golang for auth0. Currently most of the users method have been implemented but some methods are still missing optional parameters.

Getting started

To get started, first make sure you've properly set up your Golang environment and then run the

$ go get github.com/cycloidio/goat/auth0

to get the latest version of the goat.

Initialisation

In order to use the SDK:

import 	"github.com/cycloidio/goat/auth0"

var auth0Domain = "https://cycloid.eu.auth0.com" // your auth0 domain
var auth0APIBasePath = "/api/v2"                 // the API base path
var auth0Token = "XXXXXX"                        // the token you want to use

var auth0 = goat.NewAuth0(auth0Domain, auth0APIBasePath, auth0Token)

The idea behind the token variable is to be able to use different tokens, based on your needs instead of having a token that can do everything.

Calls

You can then call any of the methods that have been implemented or call arbitrary a method via the Call method. Example of re-implementing the GetUser method:

// This method
json, err := auth0.GetUser("github|testing-user")
// is identical to
json, err := auth0.Call("/users/github|testing-user", http.MethodGet, nil)

License

The MIT License (MIT)

Copyright (c) 2016 cycloid.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

goat's People

Contributors

ifraixedes avatar xescugc avatar xlr-8 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goat's Issues

Add tags to the repo for versioning

Opened this issue to tackle the "Use Semver" section of the comment of the issue #14, which was

There are a lot of tools from Vendoring in Go because Google uses monorepo so it's not an issue for them, but recently, an OSS project has the "bless" (not quite yet but) that it may be incorpored on the go tools. This project is dep and you can find the documentatio of how they resolve versioning here.

So basically the other proposal is to add taggs to the repository for versioning. This way we can deprecate the functionality according to the versioning, so in a new major we can remove the /auth0.

Add test coverage for HTTP method in call

Currently some elements of the Call method are not checked:

func (a *Auth0) Call(api_action string, method string, body []byte) ([]byte, error) {
[...]
        _, err := a.client.Get(uri)
        if err != nil {
                return nil, err
        }
[...]
        resp, err := a.client.Do(req)
        if err != nil {
                return nil, err
        }
[...]
        res_body, err := ioutil.ReadAll(resp.Body)
        if err != nil {
                return nil, err
        }

So checks should be added for:

  • Client Get
  • Client Do
  • Read Body

can't load package

go get github.com/cycloidio/goat throws the following error:
can't load package: package github.com/cycloidio/goat: no buildable Go source files in /Users/darshik/go/src/github.com/cycloidio/goat

Targeting API versions than using loose parameter

I see this API client a bit strange approach of what the README describes.

If it'd be a helper library to call the Auth0 management API, I understand that the API path (e.g. /api/v2) be a parameter, but then having function for calling specific endpoints look strange because those endpoints could change when the path change, for example, between different versions (e.g. /api/v1).

If I consider that this library is a client API for Auth0 management API, I wouldn't:

My rationale behind of currently exposing the Call and UserCall functions is that the library is pretty much work in progress and it doesn't have a function for all the endpoints, however I'm wondering if you have the same rationale and the end goal of this repo is to have a Auth0 client than a generic small wrapper library.

Change the package architecture

In issue #12 we updated the documentation to go get github.com/cycloidio/goat/auth0 to install the package.

Now

Basically the problem was that the root of the project does not have any imported code, instead all the code is in /auth0, which is not go friendly.

Proposal

We should move all the code form /auth0 to the root of the package to make the package more consistent and clear with go starndars.
But this proposal involves a bracking change, the import path would no longer be github.com/cycloidio/goat/auth0 so all the projects with this import path will have an import mismatch (if they are updated), because github.com/cycloidio/goat/auth0 will no loger exist. So this proposal brakes COMPATIBILITY.

Improve Makefile

There are a few things to improve the Makefile:

  • Append @ to each shell command which is missing it to avoid to print what's run on the target
  • Add the common help target that Cycloid uses
  • Change fmt target to use goimports
  • Change fmtcheck target to use goimports (It requires to update CI config (.travis.yml)

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.