gologin: github.com/dghubble/gologin/bitbucket Index | Files

package bitbucket

import "github.com/dghubble/gologin/bitbucket"

Package bitbucket provides Bitbucket OAuth2 login and callback handlers.


Package Files

context.go doc.go login.go verify.go


var (
    ErrUnableToGetBitbucketUser = errors.New("bitbucket: unable to get Bitbucket User")

Bitbucket login errors

func CallbackHandler Uses

func CallbackHandler(config *oauth2.Config, success, failure http.Handler) http.Handler

CallbackHandler handles Bitbucket redirection URI requests and adds the Bitbucket access token and User to the ctx. If authentication succeeds, handling delegates to the success handler, otherwise to the failure handler.

func LoginHandler Uses

func LoginHandler(config *oauth2.Config, failure http.Handler) http.Handler

LoginHandler handles Bitbucket login requests by reading the state value from the ctx and redirecting requests to the AuthURL with that state value.

func StateHandler Uses

func StateHandler(config gologin.CookieConfig, success http.Handler) http.Handler

StateHandler checks for a state cookie. If found, the state value is read and added to the ctx. Otherwise, a non-guessable value is added to the ctx and to a (short-lived) state cookie issued to the requester.

Implements OAuth 2 RFC 6749 10.12 CSRF Protection. If you wish to issue state params differently, write a http.Handler which sets the ctx state, using oauth2 WithState(ctx, state) since it is required by LoginHandler and CallbackHandler.

func WithUser Uses

func WithUser(ctx context.Context, user *User) context.Context

WithUser returns a copy of ctx that stores the Bitbucket User.

type User Uses

type User struct {
    Username    string `json:"username"`
    DisplayName string `json:"display_name"`
    Website     string `json:"website"`
    Location    string `json:"location"`
    Type        string `json:"type"` // user, team

User is a Bitbucket user.

func UserFromContext Uses

func UserFromContext(ctx context.Context) (*User, error)

UserFromContext returns the Bitbucket User from the ctx.

Package bitbucket imports 8 packages (graph). Updated 2019-08-10. Refresh now. Tools for package owners.