Documentation
¶
Index ¶
- Constants
- Variables
- func Authenticate(req *http.Request, payload []byte, date time.Time, credentials Credentials, ...)
- func Init(credentials Credentials, cache Cache)
- func InitWithCustomHTTPClient(credentials Credentials, cache Cache, httpClient *http.Client)
- func NewAccountFilter(givenName string, middleName string, surname string, username string, ...) url.Values
- func NewDefaultFilter(name string, description string, status string) url.Values
- func NewDefaultPageRequest() url.Values
- func NewEmptyFilter() url.Values
- func NewPageRequest(limit int, offset int) url.Values
- type Account
- func (account *Account) AddToGroup(group *Group) (*GroupMembership, error)
- func (account *Account) Delete() error
- func (account *Account) GetCustomData() (map[string]interface{}, error)
- func (account *Account) GetGroupMemberships(pageRequest url.Values) (*GroupMemberships, error)
- func (account *Account) RemoveFromGroup(group *Group) error
- func (account *Account) Save() error
- func (account *Account) UpdateCustomData(data map[string]interface{}) error
- type AccountPasswordResetToken
- type AccountRef
- type AccountStoreMapping
- type AccountStoreMappings
- type Accounts
- type Application
- func (app *Application) AuthenticateAccount(username string, password string) (*AccountRef, error)
- func (app *Application) CreateGroup(group *Group) error
- func (app *Application) CreateIDSiteURL(options map[string]string) (string, error)
- func (app *Application) Delete() error
- func (app *Application) GetAccountStoreMappings(pageRequest url.Values, filter url.Values) (*AccountStoreMappings, error)
- func (app *Application) GetAccounts(pageRequest url.Values, filter url.Values) (*Accounts, error)
- func (app *Application) GetGroups(pageRequest url.Values, filter url.Values) (*Groups, error)
- func (app *Application) HandleIDSiteCallback(URL string) (*IDSiteCallbackResult, error)
- func (app *Application) Purge() error
- func (app *Application) RegisterAccount(account *Account) error
- func (app *Application) RegisterSocialAccount(socialAccount *SocialAccount) (*Account, error)
- func (app *Application) ResetPassword(token string, newPassword string) (*AccountRef, error)
- func (app *Application) Save() error
- func (app *Application) SendPasswordResetEmail(username string) (*AccountPasswordResetToken, error)
- func (app *Application) ValidatePasswordResetToken(token string) (*AccountPasswordResetToken, error)
- type ApplicationRef
- type Applications
- type Cache
- type Client
- type Credentials
- type Directories
- type Directory
- func (dir *Directory) CreateGroup(group *Group) error
- func (dir *Directory) Delete() error
- func (dir *Directory) GetAccounts(pageRequest url.Values, filter url.Values) (*Accounts, error)
- func (dir *Directory) GetGroups(pageRequest url.Values, filter url.Values) (*Groups, error)
- func (dir *Directory) RegisterAccount(account *Account) error
- func (dir *Directory) RegisterSocialAccount(socialAccount *SocialAccount) (*Account, error)
- func (dir *Directory) Save() error
- type Group
- type GroupMembership
- type GroupMemberships
- type Groups
- type IDSiteCallbackResult
- type PageRequest
- type ProviderData
- type RedisCache
- type SocialAccount
- type Tenant
- func (tenant *Tenant) CreateApplication(app *Application) error
- func (tenant *Tenant) CreateDirectory(dir *Directory) error
- func (tenant *Tenant) DeleteCustomData() error
- func (tenant *Tenant) GetApplications(pageRequest url.Values, filter url.Values) (*Applications, error)
- func (tenant *Tenant) GetCustomData() (map[string]interface{}, error)
- func (tenant *Tenant) GetDirectories(pageRequest url.Values, filter url.Values) (*Directories, error)
- func (tenant *Tenant) UpdateCustomData(customData map[string]interface{}) (map[string]interface{}, error)
Constants ¶
const ( IDTerminator = "sauthc1_request" AuthenticationScheme = "SAuthc1" NL = "\n" HostHeader = "Host" AuthorizationHeader = "Authorization" StormpathDateHeader = "X-Stormpath-Date" Algorithm = "HMAC-SHA-256" SAUTHC1Id = "sauthc1Id" SAUTHC1SignedHeaders = "sauthc1SignedHeaders" SAUTHC1Signature = "sauthc1Signature" DateFormat = "20060102" TimestampFormat = "20060102T150405Z0700" )
SAuthc1 algorithm constants
Variables ¶
var BaseURL = "https://api.stormpath.com/v1/"
BaseURL defines the Stormpath API base URL
var Logger *log.Logger
Functions ¶
func Authenticate ¶
func Authenticate(req *http.Request, payload []byte, date time.Time, credentials Credentials, nonce string)
Authenticate generates the proper authentication header for the SAuthc1 algorithm use by Stormpath
func Init ¶
func Init(credentials Credentials, cache Cache)
Init initializes the underlying client that communicates with Stormpath
func InitWithCustomHTTPClient ¶
func InitWithCustomHTTPClient(credentials Credentials, cache Cache, httpClient *http.Client)
InitWithCustomHTTPClient initializes the underlying client that communicates with Stormpath with a custom http.Client
func NewAccountFilter ¶
func NewAccountFilter(givenName string, middleName string, surname string, username string, email string) url.Values
NewAccountFilter creates the url.Values for an account filter if any of the values is 0 len they won't be added to the values
func NewDefaultFilter ¶
NewDefaultFilter creates a new filter set of url.Values, default includes name, description and status
func NewDefaultPageRequest ¶
NewDefaultPageRequest is a conviniece constructor for the default PageRequest values limit = 25 offset = 0
Types ¶
type Account ¶
type Account struct { Href string `json:"href,omitempty"` Username string `json:"username,omitempty"` Email string `json:"email"` Password string `json:"password"` FullName string `json:"fullName,omitempty"` GivenName string `json:"givenName"` MiddleName string `json:"middleName,omitempty"` Surname string `json:"surname"` Status string `json:"status,omitempty"` CustomData *link `json:"customData,omitempty"` Groups *link `json:"groups,omitempty"` GroupMemberships *link `json:"groupMemberships,omitempty"` Directory *link `json:"directory,omitempty"` Tenant *link `json:"tenant,omitempty"` EmailVerificationToken *link `json:"emailVerificationToken,omitempty"` }
Account represents an Stormpath account object
See: http://docs.stormpath.com/rest/product-guide/#accounts
func NewAccount ¶
NewAccount is a conviniece constructor for an Account, it accepts all the required fields according to the Stormpath API, it returns a pointer to an Account
func (*Account) AddToGroup ¶
func (account *Account) AddToGroup(group *Group) (*GroupMembership, error)
AddToGroup adds the given account to a given group and returns the respective GroupMembership
func (*Account) GetCustomData ¶
GetCustomData returns the given account custom data as a map
func (*Account) GetGroupMemberships ¶
func (account *Account) GetGroupMemberships(pageRequest url.Values) (*GroupMemberships, error)
GetGroupMemberships returns a paged result of the group memeberships of the given account
func (*Account) RemoveFromGroup ¶
RemoveFromGroup removes the given account from the given group by searching the account groupmemberships, and deleting the corresponding one
func (*Account) Save ¶
Save updates the given account, by doing a POST to the account Href, if the account is a new account it should be created via Application.RegisterAccount
func (*Account) UpdateCustomData ¶
UpdateCustomData sets or updates the given account custom data
type AccountPasswordResetToken ¶
AccountPasswordResetToken represents an password reset token for a given account
See: http://docs.stormpath.com/rest/product-guide/#application-accounts (Reset An Account’s Password)
type AccountRef ¶
type AccountRef struct {
Account link
}
AccountRef represent a link to an account, this type of resource is return when expand is not especify, use only in account authentication
See: http://docs.stormpath.com/rest/product-guide/#application-accounts (Log In (Authenticate) an Account)
func (*AccountRef) GetAccount ¶
func (accountRef *AccountRef) GetAccount() (*Account, error)
GetAccount returns the Account from an AccountRef
type AccountStoreMapping ¶
type AccountStoreMapping struct { Href string `json:"href,omitempty"` ListIndex *int `json:"listIndex,omitempty"` IsDefaultAccountStore *bool `json:"isDefaultAccountStore,omitempty"` IsDefaultGroupStore *bool `json:"isDefaultGroupStore,omitempty"` Application link `json:"application"` AccountStore link `json:"accountStore"` }
AccountStoreMapping represents an Stormpath account store mapping
See: http://docs.stormpath.com/rest/product-guide/#account-store-mappings
func NewAccountStoreMapping ¶
func NewAccountStoreMapping(applicationHref string, accountStoreHref string) *AccountStoreMapping
NewAccountStoreMapping creates a new account store mappings
func (*AccountStoreMapping) Save ¶
func (mapping *AccountStoreMapping) Save() error
Save saves the given account store mapping
type AccountStoreMappings ¶
type AccountStoreMappings struct { Items []AccountStoreMapping `json:"items"` // contains filtered or unexported fields }
AccountStoreMappings represents a pages result of account store mappings
See: http://docs.stormpath.com/rest/product-guide/#list-account-store-mappings
type Accounts ¶
type Accounts struct { Items []Account `json:"items"` // contains filtered or unexported fields }
Accounts represents a paged result of Account objects
See: http://docs.stormpath.com/rest/product-guide/#accounts-list
type Application ¶
type Application struct { Href string `json:"href,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Status string `json:"status,omitempty"` Accounts *link `json:"accounts,omitempty"` Groups *link `json:"groups,omitempty"` Tenant *link `json:"tenant,omitempty"` PasswordResetTokens *link `json:"passwordResetTokens,omitempty"` AccountStoreMappings *link `json:"accountStoreMappings,omitempty"` DefaultAccountStoreMapping *link `json:"defaultAccountStoreMapping,omitempty"` DefaultGroupStoreMapping *link `json:"defaultGroupStoreMapping,omitempty"` }
Application represents a Stormpath application object
See: http://docs.stormpath.com/rest/product-guide/#applications
func NewApplication ¶
func NewApplication(name string) *Application
NewApplication creates a new application
func (*Application) AuthenticateAccount ¶
func (app *Application) AuthenticateAccount(username string, password string) (*AccountRef, error)
AuthenticateAccount authenticates an account against the application
See: http://docs.stormpath.com/rest/product-guide/#authenticate-an-account
func (*Application) CreateGroup ¶
func (app *Application) CreateGroup(group *Group) error
CreateGroup creates a new group in the application
See: http://docs.stormpath.com/rest/product-guide/#application-groups
func (*Application) CreateIDSiteURL ¶
func (app *Application) CreateIDSiteURL(options map[string]string) (string, error)
CreateIDSiteURL creates the IDSite URL for the application
func (*Application) Delete ¶
func (app *Application) Delete() error
Delete deletes the given applicaiton
See: http://docs.stormpath.com/rest/product-guide/#delete-an-application
func (*Application) GetAccountStoreMappings ¶
func (app *Application) GetAccountStoreMappings(pageRequest url.Values, filter url.Values) (*AccountStoreMappings, error)
GetAccountStoreMappings returns all the applications account store mappings
See: http://docs.stormpath.com/rest/product-guide/#application-account-store-mappings
func (*Application) GetAccounts ¶
GetAccounts returns all the accounts of the application
See: http://docs.stormpath.com/rest/product-guide/#application-accounts
func (*Application) GetGroups ¶
GetGroups returns all the application groups
See: http://docs.stormpath.com/rest/product-guide/#application-groups
func (*Application) HandleIDSiteCallback ¶
func (app *Application) HandleIDSiteCallback(URL string) (*IDSiteCallbackResult, error)
HandleIDSiteCallback handles the URL from an ID Site callback it parses the JWT token validates it and return an IDSiteCallbackResult with the token info + the Account if the sub was given
func (*Application) Purge ¶
func (app *Application) Purge() error
Purge deletes all the account stores before deleting the application
See: http://docs.stormpath.com/rest/product-guide/#delete-an-application
func (*Application) RegisterAccount ¶
func (app *Application) RegisterAccount(account *Account) error
RegisterAccount registers a new account into the application
See: http://docs.stormpath.com/rest/product-guide/#application-accounts
func (*Application) RegisterSocialAccount ¶
func (app *Application) RegisterSocialAccount(socialAccount *SocialAccount) (*Account, error)
RegisterSocialAccount registers a new account into the application using an external provider Google, Facebook
func (*Application) ResetPassword ¶
func (app *Application) ResetPassword(token string, newPassword string) (*AccountRef, error)
ResetPassword resets a user password based on the reset token
See: http://docs.stormpath.com/rest/product-guide/#reset-an-accounts-password
func (*Application) SendPasswordResetEmail ¶
func (app *Application) SendPasswordResetEmail(username string) (*AccountPasswordResetToken, error)
SendPasswordResetEmail sends a password reset email to the given user
See: http://docs.stormpath.com/rest/product-guide/#reset-an-accounts-password
func (*Application) ValidatePasswordResetToken ¶
func (app *Application) ValidatePasswordResetToken(token string) (*AccountPasswordResetToken, error)
ValidatePasswordResetToken validates a password reset token
See: http://docs.stormpath.com/rest/product-guide/#reset-an-accounts-password
type ApplicationRef ¶
type ApplicationRef struct {
Application link
}
ApplicationRef holds the the Href of an application
func NewApplicationRef ¶
func NewApplicationRef(href string) *ApplicationRef
NewApplicationRef creates an ApplicationHref from a URL
func (*ApplicationRef) GetApplication ¶
func (applicationRef *ApplicationRef) GetApplication() (*Application, error)
GetApplication loads an application from the given ApplicationRef
type Applications ¶
type Applications struct { Items []Application `json:"items"` // contains filtered or unexported fields }
Applications represents a paged result or applications
type Cache ¶
type Cache interface { Exists(key string) bool Set(key string, data interface{}) Get(key string, result interface{}) error Del(key string) }
Cache is a base interface for any cache provider
type Client ¶
type Client struct { Credentials Credentials HTTPClient *http.Client Cache Cache }
Client is low level REST client for any Stormpath request, it holds the credentials, an the actual http client, and the cache. The Cache can be initialize in nil and the client would simply ignore it and don't cache any response.
type Credentials ¶
Credentials represents a set of Stormpath credentials
func NewCredentialsFromFile ¶
func NewCredentialsFromFile(file string) (Credentials, error)
NewCredentialsFromFile creates a new credentials from a Stormpath key files
func NewDefaultCredentials ¶
func NewDefaultCredentials() (Credentials, error)
NewDefaultCredentials would create a new credentials based on env variables first then the default file location at ~/.config/stormpath/apiKey.properties
type Directories ¶
type Directories struct { Items []Directory `json:"items"` // contains filtered or unexported fields }
Directories represnets a paged result of directories
type Directory ¶
type Directory struct { Href string `json:"href,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Status string `json:"status,omitempty"` Accounts *link `json:"accounts,omitempty"` Groups *link `json:"groups,omitempty"` Tenant *link `json:"tenant,omitempty"` }
Directory represents a Stormpath directory object
See: http://docs.stormpath.com/rest/product-guide/#directories
func NewDirectory ¶
NewDirectory creates a new directory with the given name
func (*Directory) CreateGroup ¶
CreateGroup creates a new group in the directory
func (*Directory) GetAccounts ¶
GetAccounts returns all the accounts from the directory
func (*Directory) RegisterAccount ¶
RegisterAccount registers a new account into the directory
See: http://docs.stormpath.com/rest/product-guide/#directory-accounts
func (*Directory) RegisterSocialAccount ¶
func (dir *Directory) RegisterSocialAccount(socialAccount *SocialAccount) (*Account, error)
RegisterSocialAccount registers a new account into the application using an external provider Google, Facebook
type Group ¶
type Group struct { Href string `json:"href,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Status string `json:"status,omitempty"` CustomData *link `json:"customData,omitempty"` Accounts *link `json:"accounts,omitempty"` Tenant *link `json:"tenant,omitempty"` Directory *link `json:"directory,omitempty"` }
Group represents a Stormpath Group
See: http://docs.stormpath.com/rest/product-guide/#groups
func (*Group) GetAccounts ¶
func (*Group) GetGroupMemberships ¶
type GroupMembership ¶
type GroupMembership struct { Href string `json:"href,omitempty"` Account link `json:"account"` Group link `json:"group"` }
func NewGroupMembership ¶
func NewGroupMembership(accountHref string, groupHref string) *GroupMembership
func (*GroupMembership) Delete ¶
func (groupmembership *GroupMembership) Delete() error
func (*GroupMembership) GetAccount ¶
func (groupmembership *GroupMembership) GetAccount() (*Account, error)
func (*GroupMembership) GetGroup ¶
func (groupmembership *GroupMembership) GetGroup() (*Group, error)
type GroupMemberships ¶
type GroupMemberships struct { Items []GroupMembership `json:"items"` // contains filtered or unexported fields }
type Groups ¶
type Groups struct { Items []Groups `json:"items"` // contains filtered or unexported fields }
Groups represent a paged result of groups
type IDSiteCallbackResult ¶
IDSiteCallbackResult holds the ID Site callback parsed JWT token information + the acccount if one was given
type PageRequest ¶
PageRequest contains the limit and offset values for any paginated Stormpath request
type ProviderData ¶
type RedisCache ¶
RedisCache is the default provided implementation of the Cache interface using Redis as backend
func (RedisCache) Exists ¶
func (r RedisCache) Exists(key string) bool
Exists returns true if the key exists in the cache false otherwise
func (RedisCache) Get ¶
func (r RedisCache) Get(key string, result interface{}) error
Get returns the data store under key it should return an error if any occur
func (RedisCache) Set ¶
func (r RedisCache) Set(key string, data interface{})
Set stores data in the the cache for the given key
type SocialAccount ¶
type SocialAccount struct {
Data ProviderData `json:"providerData"`
}
type Tenant ¶
type Tenant struct { Href string `json:"href"` Name string `json:"name"` Key string `json:"key"` CustomData link `json:"customData"` Applications link `json:"applications"` Directories link `json:"directories"` }
Tenant represents a Stormpath tennat see http://docs.stormpath.com/rest/product-guide/#tenants
func CurrentTenant ¶
CurrentTenant returns the current tenant see http://docs.stormpath.com/rest/product-guide/#retrieve-the-current-tenant
func (*Tenant) CreateApplication ¶
func (tenant *Tenant) CreateApplication(app *Application) error
CreateApplication creates a new application for the given tenant
See: http://docs.stormpath.com/rest/product-guide/#tenant-applications
func (*Tenant) CreateDirectory ¶
CreateDirectory creates a new directory for the given tenant
See: http://docs.stormpath.com/rest/product-guide/#tenant-directories
func (*Tenant) DeleteCustomData ¶
DeleteCustomData deletes all the tenants custom data
See: http://docs.stormpath.com/rest/product-guide/#custom-data
func (*Tenant) GetApplications ¶
func (tenant *Tenant) GetApplications(pageRequest url.Values, filter url.Values) (*Applications, error)
GetApplications returns all the applications for the given tenant
See: http://docs.stormpath.com/rest/product-guide/#tenant-applications
func (*Tenant) GetCustomData ¶
GetCustomData gets the tenant custom data map
See: http://docs.stormpath.com/rest/product-guide/#custom-data
func (*Tenant) GetDirectories ¶
func (tenant *Tenant) GetDirectories(pageRequest url.Values, filter url.Values) (*Directories, error)
GetDirectories returns all the directories for the given tenant
See: http://docs.stormpath.com/rest/product-guide/#tenant-directories
func (*Tenant) UpdateCustomData ¶
func (tenant *Tenant) UpdateCustomData(customData map[string]interface{}) (map[string]interface{}, error)
UpdateCustomData updates the tenant custom data and returns that updated custom data as a map[string]interface
See: http://docs.stormpath.com/rest/product-guide/#custom-data