crowd

package module
v0.0.0-...-9c6f178 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 10 Imported by: 6

README

go-crowd

Go library for interacting with Atlassian Crowd

Client example

client, err := crowd.New("crowd_app_user", 
                        "crowd_app_password", 
                        "crowd service URL")

user, err := client.Authenticate("testuser", "testpass")
if err != nil {
    /*
    failure or reject from crowd. check if err = reason from 
    https://developer.atlassian.com/display/CROWDDEV/Using+the+Crowd+REST+APIs#UsingtheCrowdRESTAPIs-HTTPResponseCodesandErrorResponses
    */
}

// if auth successful, user contains user information

Documentation

Overview

Package crowd provides methods for interacting with the Atlassian Crowd authentication, directory integration, and Single Sign-On system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CookieConfig

type CookieConfig struct {
	XMLName struct{} `xml:"cookie-config"`
	Domain  string   `xml:"domain"`
	Secure  bool     `xml:"secure"`
	Name    string   `xml:"name"`
}

CookieConfig holds configuration values needed to set a Crowd SSO cookie.

type Crowd

type Crowd struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Crowd represents your Crowd (client) Application settings

func New

func New(appuser string, apppass string, baseurl string) (Crowd, error)

New initializes & returns a Crowd object.

func (*Crowd) Authenticate

func (c *Crowd) Authenticate(user string, pass string) (User, error)

Authenticate a user & password against Crowd. Returns error on failure or account lockout. Success is a populated User with nil error.

func (*Crowd) CreateGroup

func (c *Crowd) CreateGroup(name string, description string) (status bool)

CreateGroup creates a new group

func (*Crowd) GetCookieConfig

func (c *Crowd) GetCookieConfig() (CookieConfig, error)

GetCookieConfig returns settings needed to set a Crowd SSO cookie.

func (*Crowd) GetDirectGroups

func (c *Crowd) GetDirectGroups(user string) ([]*Group, error)

GetDirectGroups retrieves a list of groups of which a user is a direct member

func (*Crowd) GetGroup

func (c *Crowd) GetGroup(name string) (*Group, error)

GetGroup returns a group

func (*Crowd) GetGroups

func (c *Crowd) GetGroups(user string, donested bool) ([]*Group, error)

GetGroups retrieves a list of groups of which a user is a direct (and nested if donested is true) member.

func (*Crowd) GetNestedGroups

func (c *Crowd) GetNestedGroups(user string) ([]*Group, error)

GetNestedGroups retrieves a list of groups of which a user is a direct or nested member

func (*Crowd) GetSession

func (c *Crowd) GetSession(token string) (s Session, err error)

GetSession gets SSO session information by token

func (*Crowd) GetUser

func (c *Crowd) GetUser(user string) (User, error)

GetUser retrieves user information

func (*Crowd) InvalidateSession

func (c *Crowd) InvalidateSession(token string) error

InvalidateSession invalidates SSO session token. Returns error on failure.

func (*Crowd) NewSession

func (c *Crowd) NewSession(user string, pass string, address string) (Session, error)

NewSession authenticates a user and starts a SSO session if valid.

func (*Crowd) ValidateSession

func (c *Crowd) ValidateSession(token string, clientaddr string) (Session, error)

ValidateSession validates a SSO token against Crowd. Returns error on failure or account lockout. Success is a populated Session with nil error.

type Error

type Error struct {
	XMLName struct{} `xml:"error"`
	Reason  string   `xml:"reason"`
	Message string   `xml:"message"`
}

Error represents a error response from Crowd. Error reasons are documented at https://developer.atlassian.com/display/CROWDDEV/Using+the+Crowd+REST+APIs#UsingtheCrowdRESTAPIs-HTTPResponseCodesandErrorResponses

type Group

type Group struct {
	Name string `json:"name"`
	Link Link   `json:"link"`
}

Group represents a group in Crowd

type GroupInfo

type GroupInfo struct {
	Expand string `json:"expand"`
	Link   struct {
		Href string `json:"href"`
		Rel  string `json:"rel"`
	} `json:"link"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Active      bool   `json:"active"`
	Attributes  struct {
		Attributes []interface{} `json:"attributes"`
		Link       struct {
			Href string `json:"href"`
			Rel  string `json:"rel"`
		} `json:"link"`
	} `json:"attributes"`
}

GroupInfo returns information about a group

type Link struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

Link is a child of Group

type Session

type Session struct {
	XMLName struct{}  `xml:"session"`
	Expand  string    `xml:"expand,attr"`
	Token   string    `xml:"token"`
	User    User      `xml:"user,omitempty"`
	Created time.Time `xml:"created-date"`
	Expires time.Time `xml:"expiry-date"`
}

Session represents a single sign-on (SSO) session in Crowd

type User

type User struct {
	XMLName     struct{} `xml:"user"`
	UserName    string   `xml:"name,attr"`
	FirstName   string   `xml:"first-name"`
	LastName    string   `xml:"last-name"`
	DisplayName string   `xml:"display-name"`
	Email       string   `xml:"email"`
	Active      bool     `xml:"active"`
	Key         string   `xml:"key"`
}

User represents a user in Crowd

Directories

Path Synopsis
Package crowdauth provides middleware for Crowd SSO logins Goals: 1) drop-in authentication against Crowd SSO 2) make it easy to use Crowd SSO as part of your own auth flow
Package crowdauth provides middleware for Crowd SSO logins Goals: 1) drop-in authentication against Crowd SSO 2) make it easy to use Crowd SSO as part of your own auth flow

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL