stormpath

package module
v0.0.0-...-17ec282 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2016 License: Apache-2.0 Imports: 25 Imported by: 0

README

Go SDK for the Stormpath API

Develop:

Build Status codecov.io

Master:

Build Status codecov.io

Usage

Core

go get github.com/jarias/stormpath-sdk-go

import "github.com/jarias/stormpath-sdk-go"
import "fmt"

//Load the configuration according to the StormPath framework spec 
//See: https://github.com/stormpath/stormpath-sdk-spec/blob/master/specifications/config.md
clientConfig, err := stormpath.LoadConfiguration()

if err != nil {
    stormpath.Logger.Panicf("[ERROR] Couldn't load Stormpath client configuration: %s", err)
}

//Init the client with the loaded config and no specific cache, 
//note that if the cache is enabled via config the default local cache would be used
stormpath.Init(clientConfig, nil)

//Get the current tenant
tenant, _ := stormpath.CurrentTenant()

//Get the tenat applications
apps, _ := tenant.GetApplications(stormpath.MakeApplicationCriteria().NameEq("test app"))

//Get the first application
app := apps.Items[0]

//Authenticate a user against the app
account, _ := app.AuthenticateAccount("username", "password")

fmt.Println(account)

Web

See web/example/example.go

Features:

  • Cache with a sample local in-memory implementation
  • Almost 100% of the Stormpath API implemented
  • Load credentials via properties file or env variables
  • Load client configuration according to Stormpath framework spec
  • Requests are authenticated via Stormpath SAuthc1 algorithm only
  • Web extension according to the Stormpath Spec

Debugging

If you need to trace all requests done to stormpath you can enable debugging in the logs by setting the environment variable STORMPATH_LOG_LEVEL=DEBUG the default level is ERROR.

Contributing

Pull request are more than welcome, all pull requests should be from and directed to the develop branch NOT master.

Please make sure you add tests ;)

Development requirements:

  • Go 1.6+
  • Testify go get github.com/stretchr/testify/assert
  • An Stormpath account (for integration testing)

Running the test suite

Env variables:

export STORMPATH_API_KEY_ID=XXXX
export STORMPATH_API_KEY_SECRET=XXXX
go test . -cover -covermode=atomic

I'm aiming at 85% test coverage not yet met but thats the goal.

License

Copyright 2014, 2015, 2016 Julio Arias

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

View Source
const (
	Name        = "name"
	Description = "description"
	Status      = "status"
)
View Source
const (
	Facebook = "facebook"
	Google   = "google"
	GitHub   = "github"
	LinkedIn = "linkedin"
)
View Source
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"
	EQ                   = '='
	SPACE                = ' '
	SLASH                = '/'
	AMP                  = '&'
	CS                   = ", "
	COMMA                = ','
	COLON                = ':'
	SemiColon            = ';'
	EMPTY                = ""
)

SAuthc1 algorithm constants

View Source
const (
	Enabled                   = "ENABLED"
	Disabled                  = "DISABLED"
	Unverified                = "UNVERIFIED"
	ApplicationJSON           = "application/json"
	ApplicationFormURLencoded = "application/x-www-form-urlencoded"
	TextPlain                 = "text/plain"
	TextHTML                  = "text/html"
	ContentTypeHeader         = "Content-Type"
	AcceptHeader              = "Accept"
	UserAgentHeader           = "User-Agent"
)

Variables

View Source
var DefaultPageRequest = PageRequest{25, 0}
View Source
var Logger *log.Logger

Logger library wide logger

Functions

func Authenticate

func Authenticate(req *http.Request, payload []byte, date time.Time, apiKeyID string, apiKeySecret string, nonce string)

Authenticate generates the proper authentication header for the SAuthc1 algorithm use by Stormpath

func GetToken

func GetToken(href string) string

func Init

func Init(clientConfiguration ClientConfiguration, cache Cache)

Init initializes the underlying client that communicates with Stormpath

func InitLog

func InitLog()

func JWT

func JWT(claims jwt.Claims, extraHeaders map[string]interface{}) string

JWT helper function to create JWT token strings with the given claims, extra header values, and sign with client API Key Secret using SigningMethodHS256 algorithm

func NewPageRequest

func NewPageRequest(limit int, offset int) url.Values

NewPageRequest is a conviniece constructor for a PageRequest

func ParseJWT

func ParseJWT(token string, claims jwt.Claims) *jwt.Token

Types

type APIKey

type APIKey struct {
	ID      string   `json:"id"`
	Secret  string   `json:"secret"`
	Status  string   `json:"status"`
	Account *Account `json:"account"`
	Tenant  *Tenant  `json:"tenant"`
	// contains filtered or unexported fields
}

func GetAPIKey

func GetAPIKey(href string, criteria Criteria) (*APIKey, error)

func (*APIKey) Delete

func (k *APIKey) Delete() error

func (APIKey) IsCacheable

func (r APIKey) IsCacheable() bool

func (*APIKey) Update

func (k *APIKey) Update() error

type APIKeyCriteria

type APIKeyCriteria struct {
	// contains filtered or unexported fields
}

func MakeAPIKeyCriteria

func MakeAPIKeyCriteria() APIKeyCriteria

func MakeAPIKeysCriteria

func MakeAPIKeysCriteria() APIKeyCriteria

func (APIKeyCriteria) Limit

func (c APIKeyCriteria) Limit(limit int) Criteria

func (APIKeyCriteria) Offset

func (c APIKeyCriteria) Offset(offset int) Criteria

func (APIKeyCriteria) ToQueryString

func (c APIKeyCriteria) ToQueryString() string

func (APIKeyCriteria) WithAccount

func (c APIKeyCriteria) WithAccount() APIKeyCriteria

func (APIKeyCriteria) WithTenant

func (c APIKeyCriteria) WithTenant() APIKeyCriteria

type APIKeys

type APIKeys struct {
	Items []APIKey `json:"items,omitempty"`
	// contains filtered or unexported fields
}

func (APIKeys) GetLimit

func (r APIKeys) GetLimit() int

func (APIKeys) GetOffset

func (r APIKeys) GetOffset() int

func (APIKeys) IsCacheable

func (r APIKeys) IsCacheable() bool

type AccessTokenClaims

type AccessTokenClaims struct {
	jwt.StandardClaims
	RefreshTokenID string `json:"rti,omitempty"`
}

AccessTokenClaims are the JWT for a Stormpath OAuth2 access token

type Account

type Account struct {
	Username               string            `json:"username,omitempty"`
	Email                  string            `json:"email,omitempty"`
	Password               string            `json:"password,omitempty"`
	FullName               string            `json:"fullName,omitempty"`
	GivenName              string            `json:"givenName,omitempty"`
	MiddleName             string            `json:"middleName,omitempty"`
	Surname                string            `json:"surname,omitempty"`
	Status                 string            `json:"status,omitempty"`
	Groups                 *Groups           `json:"groups,omitempty"`
	GroupMemberships       *GroupMemberships `json:"groupMemberships,omitempty"`
	Directory              *Directory        `json:"directory,omitempty"`
	Tenant                 *Tenant           `json:"tenant,omitempty"`
	EmailVerificationToken *resource         `json:"emailVerificationToken"`
	AccessTokens           *OAuthTokens      `json:"accessTokens,omitempty"`
	RefreshTokens          *OAuthTokens      `json:"refreshTokens,omitempty"`
	ProviderData           *ProviderData     `json:"providerData,omitempty"`
	APIKeys                *APIKeys          `json:"apiKeys,omitempty"`
	Applications           *Applications     `json:"applications,omitempty"`
	// contains filtered or unexported fields
}

Account represents an Stormpath account object

See: http://docs.stormpath.com/rest/product-guide/#accounts

func GetAccount

func GetAccount(href string, criteria Criteria) (*Account, error)

GetAccount fetches an account by href and criteria

func NewAccount

func NewAccount(username, password, email, givenName, surname string) *Account

NewAccount returns a pointer to an Account with the minimum data required

func VerifyEmailToken

func VerifyEmailToken(token string) (*Account, error)

VerifyEmailToken verifies an email verification token associated with an account

See: http://docs.stormpath.com/rest/product-guide/#account-verify-email

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) CreateAPIKey

func (account *Account) CreateAPIKey() (*APIKey, error)

func (*Account) DeleteCustomData

func (r *Account) DeleteCustomData() error

DeleteCustomData deletes all the resource custom data

See: http://docs.stormpath.com/rest/product-guide/#custom-data

func (*Account) GetAccessTokens

func (account *Account) GetAccessTokens(criteria OAuthTokenCriteria) (*OAuthTokens, error)

GetAccessTokens returns the acounts's accessToken collection

func (*Account) GetCustomData

func (r *Account) GetCustomData() (CustomData, error)

GetCustomData returns the given resource custom data

See: http://docs.stormpath.com/rest/product-guide/#custom-data

func (*Account) GetGroupMemberships

func (account *Account) GetGroupMemberships(criteria Criteria) (*GroupMemberships, error)

GetGroupMemberships returns a paged result of the group memeberships of the given account

func (*Account) GetRefreshTokens

func (account *Account) GetRefreshTokens(criteria OAuthTokenCriteria) (*OAuthTokens, error)

GetRefreshTokens returns the account's refreshToken collection

func (*Account) Refresh

func (account *Account) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*Account) RemoveFromGroup

func (account *Account) RemoveFromGroup(group *Group) error

RemoveFromGroup removes the given account from the given group by searching the account groupmemberships, and deleting the corresponding one

func (*Account) Update

func (account *Account) Update() error

Update updates the given resource, by doing a POST to the resource Href

func (*Account) UpdateCustomData

func (r *Account) UpdateCustomData(customData CustomData) (CustomData, error)

UpdateCustomData sets or updates the given resource custom data

See: http://docs.stormpath.com/rest/product-guide/#custom-data

type AccountCreationPolicy

type AccountCreationPolicy struct {
	VerificationEmailStatus           string          `json:"verificationEmailStatus,omitempty"`
	VerificationEmailTemplates        *EmailTemplates `json:"verificationEmailTemplates,omitempty"`
	VerificationSuccessEmailStatus    string          `json:"verificationSuccessEmailStatus,omitempty"`
	VerificationSuccessEmailTemplates *EmailTemplates `json:"verificationSuccessEmailTemplates,omitempty"`
	WelcomeEmailStatus                string          `json:"welcomeEmailStatus,omitempty"`
	WelcomeEmailTemplates             *EmailTemplates `json:"welcomeEmailTemplates,omitempty"`
	// contains filtered or unexported fields
}

AccountCreationPolicy represents a directory account creation policy object

See: http://docs.stormpath.com/rest/product-guide/#directory-account-creation-policy

func (*AccountCreationPolicy) Delete

func (r *AccountCreationPolicy) Delete() error

Delete deletes the given account, it wont modify the calling account

func (*AccountCreationPolicy) GetVerificationEmailTemplates

func (policy *AccountCreationPolicy) GetVerificationEmailTemplates() (*EmailTemplates, error)

GetVerificationEmailTemplates loads the policy VerificationEmailTemplates collection and returns it

func (*AccountCreationPolicy) GetVerificationSuccessEmailTemplates

func (policy *AccountCreationPolicy) GetVerificationSuccessEmailTemplates() (*EmailTemplates, error)

GetVerificationSuccessEmailTemplates loads the policy VerificationSuccessEmailTemplates collection and returns it

func (*AccountCreationPolicy) GetWelcomeEmailTemplates

func (policy *AccountCreationPolicy) GetWelcomeEmailTemplates() (*EmailTemplates, error)

GetWelcomeEmailTemplates loads the policy WelcomeEmailTemplates collection and returns it

func (AccountCreationPolicy) IsCacheable

func (r AccountCreationPolicy) IsCacheable() bool

func (*AccountCreationPolicy) Refresh

func (policy *AccountCreationPolicy) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*AccountCreationPolicy) Update

func (policy *AccountCreationPolicy) Update() error

Update updates the given resource, by doing a POST to the resource Href

type AccountCriteria

type AccountCriteria struct {
	// contains filtered or unexported fields
}

func MakeAccountCriteria

func MakeAccountCriteria() AccountCriteria

func MakeAccountsCriteria

func MakeAccountsCriteria() AccountCriteria

func (AccountCriteria) EmailEq

func (c AccountCriteria) EmailEq(email string) AccountCriteria

func (AccountCriteria) GivenNameEq

func (c AccountCriteria) GivenNameEq(givenName string) AccountCriteria

func (AccountCriteria) Limit

func (c AccountCriteria) Limit(limit int) Criteria

func (AccountCriteria) MiddleNameEq

func (c AccountCriteria) MiddleNameEq(middleName string) AccountCriteria

func (AccountCriteria) Offset

func (c AccountCriteria) Offset(offset int) Criteria

func (AccountCriteria) StatusEq

func (c AccountCriteria) StatusEq(status string) AccountCriteria

func (AccountCriteria) SurnameEq

func (c AccountCriteria) SurnameEq(surname string) AccountCriteria

func (AccountCriteria) ToQueryString

func (c AccountCriteria) ToQueryString() string

func (AccountCriteria) UsernameEq

func (c AccountCriteria) UsernameEq(username string) AccountCriteria

func (AccountCriteria) WithAPIKeys

func (c AccountCriteria) WithAPIKeys() AccountCriteria

func (AccountCriteria) WithApplications

func (c AccountCriteria) WithApplications() AccountCriteria

func (AccountCriteria) WithCustomData

func (c AccountCriteria) WithCustomData() AccountCriteria

func (AccountCriteria) WithDirectory

func (c AccountCriteria) WithDirectory() AccountCriteria

func (AccountCriteria) WithGroupMemberships

func (c AccountCriteria) WithGroupMemberships(pageRequest PageRequest) AccountCriteria

func (AccountCriteria) WithGroups

func (c AccountCriteria) WithGroups(pageRequest PageRequest) AccountCriteria

func (AccountCriteria) WithProviderData

func (c AccountCriteria) WithProviderData() AccountCriteria

func (AccountCriteria) WithTenant

func (c AccountCriteria) WithTenant() AccountCriteria

type AccountPasswordResetToken

type AccountPasswordResetToken struct {
	Href    string
	Email   string
	Account Account
}

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 AccountStoreMapping

type AccountStoreMapping struct {
	ListIndex             *int         `json:"collectionResourceIndex,omitempty"`
	IsDefaultAccountStore *bool        `json:"isDefaultAccountStore,omitempty"`
	IsDefaultGroupStore   *bool        `json:"isDefaultGroupStore,omitempty"`
	Application           *Application `json:"application,omitempty"`
	AccountStore          *resource    `json:"accountStore,omitempty"`
	// contains filtered or unexported fields
}

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) Delete

func (r *AccountStoreMapping) Delete() error

Delete deletes the given account, it wont modify the calling account

func (*AccountStoreMapping) IsAccountStoreDirectory

func (mapping *AccountStoreMapping) IsAccountStoreDirectory() bool

func (AccountStoreMapping) IsCacheable

func (r AccountStoreMapping) IsCacheable() bool

func (*AccountStoreMapping) Save

func (mapping *AccountStoreMapping) Save() error

Save saves the given account store mapping

type AccountStoreMappingCriteria

type AccountStoreMappingCriteria struct {
	// contains filtered or unexported fields
}

func MakeAccountStoreMappingCriteria

func MakeAccountStoreMappingCriteria() AccountStoreMappingCriteria

func MakeAccountStoreMappingsCriteria

func MakeAccountStoreMappingsCriteria() AccountStoreMappingCriteria

func (AccountStoreMappingCriteria) Limit

func (c AccountStoreMappingCriteria) Limit(limit int) Criteria

func (AccountStoreMappingCriteria) Offset

func (c AccountStoreMappingCriteria) Offset(offset int) Criteria

func (AccountStoreMappingCriteria) ToQueryString

func (c AccountStoreMappingCriteria) ToQueryString() string

func (AccountStoreMappingCriteria) WithApplication

type AccountStoreMappings

type AccountStoreMappings struct {
	Items []AccountStoreMapping `json:"items,omitempty"`
	// contains filtered or unexported fields
}

AccountStoreMappings represents a pages result of account store mappings

See: http://docs.stormpath.com/rest/product-guide/#collectionResource-account-store-mappings

func (AccountStoreMappings) GetLimit

func (r AccountStoreMappings) GetLimit() int

func (AccountStoreMappings) GetOffset

func (r AccountStoreMappings) GetOffset() int

func (AccountStoreMappings) IsCacheable

func (r AccountStoreMappings) IsCacheable() bool

type Accounts

type Accounts struct {
	Items []Account `json:"items,omitempty"`
	// contains filtered or unexported fields
}

Accounts represents a paged result of Account objects

See: http://docs.stormpath.com/rest/product-guide/#accounts-collectionResource

func (Accounts) GetLimit

func (r Accounts) GetLimit() int

func (Accounts) GetOffset

func (r Accounts) GetOffset() int

func (Accounts) IsCacheable

func (r Accounts) IsCacheable() bool

type Application

type Application struct {
	Name                       string                `json:"name,omitempty"`
	Description                string                `json:"description,omitempty"`
	Status                     string                `json:"status,omitempty"`
	Groups                     *Groups               `json:"groups,omitempty"`
	Tenant                     *Tenant               `json:"tenant,omitempty"`
	PasswordResetTokens        *resource             `json:"passwordResetTokens,omitempty"`
	AccountStoreMappings       *AccountStoreMappings `json:"accountStoreMappings,omitempty"`
	DefaultAccountStoreMapping *AccountStoreMapping  `json:"defaultAccountStoreMapping,omitempty"`
	DefaultGroupStoreMapping   *AccountStoreMapping  `json:"defaultGroupStoreMapping,omitempty"`
	OAuthPolicy                *OAuthPolicy          `json:"oAuthPolicy,omitempty"`
	APIKeys                    *APIKeys              `json:"apiKeys,omitempty"`
	// contains filtered or unexported fields
}

Application represents a Stormpath application object

See: http://docs.stormpath.com/rest/product-guide/#applications

func GetApplication

func GetApplication(href string, criteria Criteria) (*Application, error)

GetApplication loads an application by href and criteria

func NewApplication

func NewApplication(name string) *Application

NewApplication creates a new application

func (*Application) AuthenticateAccount

func (app *Application) AuthenticateAccount(username string, password string) (*Account, 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 IDSiteOptions) (string, error)

CreateIDSiteURL creates the IDSite URL for the application

func (*Application) GetAPIKey

func (app *Application) GetAPIKey(apiKeyID string, criteria APIKeyCriteria) (*APIKey, error)

func (*Application) GetAccountStoreMappings

func (app *Application) GetAccountStoreMappings(criteria Criteria) (*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

func (r *Application) GetAccounts(criteria Criteria) (*Accounts, error)

GetAccounts returns all the accounts of the application

See: http://docs.stormpath.com/rest/product-guide/#application-accounts

func (*Application) GetDefaultAccountStoreMapping

func (app *Application) GetDefaultAccountStoreMapping(criteria Criteria) (*AccountStoreMapping, error)

func (*Application) GetGroups

func (app *Application) GetGroups(criteria Criteria) (*Groups, error)

GetGroups returns all the application groups

See: http://docs.stormpath.com/rest/product-guide/#application-groups

func (*Application) GetOAuthPolicy

func (app *Application) GetOAuthPolicy() (*OAuthPolicy, error)

GetOAuthPolicy return the application OAuthPolicy

func (*Application) GetOAuthToken

func (app *Application) GetOAuthToken(username string, password string) (*OAuthResponse, error)

GetOAuthToken creates a OAuth2 token response for a given user credentials

func (*Application) GetOAuthTokenStormpathGrantType

func (app *Application) GetOAuthTokenStormpathGrantType(token string) (*OAuthResponse, error)

func (*Application) HandleCallback

func (app *Application) HandleCallback(URL string) (*CallbackResult, error)

HandleCallback handles the URL from an ID Site callback or SAML callback it parses the JWT token validates it and return an CallbackResult 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) Refresh

func (app *Application) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*Application) RefreshOAuthToken

func (app *Application) RefreshOAuthToken(refreshToken string) (*OAuthResponse, error)

RefreshOAuthToken refreshes an OAuth2 token using the provided refresh_token and returns a new OAuth reponse

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

See: http://docs.stormpath.com/rest/product-guide/#accessing-accounts-with-google-authorization-codes-or-an-access-tokens

func (*Application) ResendVerificationEmail

func (app *Application) ResendVerificationEmail(email string) error

ResendVerificationEmail resends the verification email to the given email address

See: https://docs.stormpath.com/rest/product-guide/latest/accnt_mgmt.html#how-to-verify-an-account-s-email

func (*Application) ResetPassword

func (app *Application) ResetPassword(token string, newPassword string) (*Account, 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(email 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) Update

func (app *Application) Update() error

Update updates the given resource, by doing a POST to the resource Href

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

func (*Application) ValidateToken

func (app *Application) ValidateToken(token string) (*OAuthToken, error)

ValidateToken against the application

type ApplicationCriteria

type ApplicationCriteria struct {
	// contains filtered or unexported fields
}

func MakeApplicationCriteria

func MakeApplicationCriteria() ApplicationCriteria

func MakeApplicationsCriteria

func MakeApplicationsCriteria() ApplicationCriteria

func (ApplicationCriteria) DescriptionEq

func (c ApplicationCriteria) DescriptionEq(description string) ApplicationCriteria

func (ApplicationCriteria) Limit

func (c ApplicationCriteria) Limit(limit int) Criteria

func (ApplicationCriteria) NameEq

func (ApplicationCriteria) Offset

func (c ApplicationCriteria) Offset(offset int) Criteria

func (ApplicationCriteria) StatusEq

func (c ApplicationCriteria) StatusEq(status string) ApplicationCriteria

func (ApplicationCriteria) ToQueryString

func (c ApplicationCriteria) ToQueryString() string

func (ApplicationCriteria) WithAccessTokens

func (c ApplicationCriteria) WithAccessTokens(pageRequest PageRequest) ApplicationCriteria

func (ApplicationCriteria) WithAccountStoreMappings

func (c ApplicationCriteria) WithAccountStoreMappings(pageRequest PageRequest) ApplicationCriteria

func (ApplicationCriteria) WithAccounts

func (c ApplicationCriteria) WithAccounts(pageRequest PageRequest) ApplicationCriteria

func (ApplicationCriteria) WithCustomData

func (c ApplicationCriteria) WithCustomData() ApplicationCriteria

func (ApplicationCriteria) WithDefaultAccountStoreMapping

func (c ApplicationCriteria) WithDefaultAccountStoreMapping() ApplicationCriteria

func (ApplicationCriteria) WithDefaultGroupStoreMapping

func (c ApplicationCriteria) WithDefaultGroupStoreMapping() ApplicationCriteria

func (ApplicationCriteria) WithGroups

func (c ApplicationCriteria) WithGroups(pageRequest PageRequest) ApplicationCriteria

func (ApplicationCriteria) WithRefreshTokens

func (c ApplicationCriteria) WithRefreshTokens(pageRequest PageRequest) ApplicationCriteria

func (ApplicationCriteria) WithTenant

type Applications

type Applications struct {
	Items []Application `json:"items,omitempty"`
	// contains filtered or unexported fields
}

Applications represents a paged result or applications

func (Applications) GetLimit

func (r Applications) GetLimit() int

func (Applications) GetOffset

func (r Applications) GetOffset() int

func (Applications) IsCacheable

func (r Applications) IsCacheable() bool

type AuthResult

type AuthResult interface {
	GetAccount() *Account
}

type AuthenticationResult

type AuthenticationResult struct {
	Account *Account
}

AuthenticationResult base authentication result for all authenticators

func (*AuthenticationResult) GetAccount

func (ar *AuthenticationResult) GetAccount() *Account

type Authenticator

type Authenticator struct {
	Application *Application
}

Authenticator is the base authenticator type

See https://github.com/stormpath/stormpath-sdk-spec/blob/master/specifications/authenticators.md

type BasicAuthenticator

type BasicAuthenticator Authenticator

BasicAuthenticator will authenticate the API Key and Secret of a Stormpath Account object. Authentication should succeed only if the following are true:

* The provided API Key and Secret exist for an account that is reachable by the application. * The API Key is not disabled. * The Account is not disabled.

func NewBasicAuthenticator

func NewBasicAuthenticator(application *Application) BasicAuthenticator

NewBasicAuthenticator returns a BasicAuthenticator for the given application

func (BasicAuthenticator) Authenticate

func (a BasicAuthenticator) Authenticate(accountAPIKey, accountAPISecret string) (*AuthenticationResult, error)

Authenticate authenticates the given account APIKey and APISecret

type Cache

type Cache interface {
	Exists(key string) bool
	Set(key string, data []byte)
	Get(key string) []byte
	Del(key string)
}

Cache is a base interface for any cache provider

type Cacheable

type Cacheable interface {
	IsCacheable() bool
}

Cacheable determines if the implementor should be cached or not

type CallbackResult

type CallbackResult struct {
	Account *Account
	State   string
	IsNew   bool
	Status  string
}

CallbackResult holds the ID Site callback parsed JWT token information + the acccount if one was given

type Claims

type Claims struct {
	EXP int64  `json:"exp"`
	IAT int64  `json:"iat"`
	ISS string `json:"iss"`
	JTI string `json:"jti"`
	RTI string `json:"rti"`
	SUB string `json:"sub"`
}

Claims represents the expanded JWT claims

type Client

type Client struct {
	ClientConfiguration ClientConfiguration
	HTTPClient          *http.Client
	Cache               Cache
	WebSDKToken         string
}

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.

func GetClient

func GetClient() *Client

GetClient returns the configured client

type ClientConfiguration

type ClientConfiguration struct {
	APIKeyFile           string
	APIKeyID             string
	APIKeySecret         string
	CacheManagerEnabled  bool
	CacheTTL             time.Duration
	CacheTTI             time.Duration
	BaseURL              string
	ConnectionTimeout    int
	AuthenticationScheme string
	ProxyPort            int
	ProxyHost            string
	ProxyUsername        string
	ProxyPassword        string
}

ClientConfiguration representd the overall SDK configuration options

func LoadConfiguration

func LoadConfiguration() (ClientConfiguration, error)

LoadConfiguration loads the configuration from the default locations

func LoadConfigurationWithCreds

func LoadConfigurationWithCreds(key string, secret string) ClientConfiguration

func (ClientConfiguration) GetJWTSigningKey

func (config ClientConfiguration) GetJWTSigningKey() []byte

GetJWTSigningKey returns the API Key Secret as a []byte to sign JWT tokens

type Criteria

type Criteria interface {
	ToQueryString() string
	Offset(offset int) Criteria
	Limit(limit int) Criteria
}

type CustomData

type CustomData map[string]interface{}

CustomData represents Stormpath's custom data resouce

func (CustomData) IsCacheable

func (customData CustomData) IsCacheable() bool

type Directories

type Directories struct {
	Items []Directory `json:"items,omitempty"`
	// contains filtered or unexported fields
}

Directories represnets a paged result of directories

func (Directories) GetLimit

func (r Directories) GetLimit() int

func (Directories) GetOffset

func (r Directories) GetOffset() int

func (Directories) IsCacheable

func (r Directories) IsCacheable() bool

type Directory

type Directory struct {
	Name                  string                 `json:"name,omitempty"`
	Description           string                 `json:"description,omitempty"`
	Status                string                 `json:"status,omitempty"`
	Groups                *Groups                `json:"groups,omitempty"`
	Tenant                *Tenant                `json:"tenant,omitempty"`
	Provider              *Provider              `json:"provider,omitempty"`
	AccountCreationPolicy *AccountCreationPolicy `json:"accountCreationPolicy,omitempty"`
	PasswordPolicy        *PasswordPolicy        `json:"passwordPolicy,omitempty"`
	// contains filtered or unexported fields
}

Directory represents a Stormpath directory object

See: http://docs.stormpath.com/rest/product-guide/#directories

func GetDirectory

func GetDirectory(href string, criteria Criteria) (*Directory, error)

GetDirectory loads a directory by href and criteria

func NewDirectory

func NewDirectory(name string) *Directory

NewDirectory creates a new directory with the given name

func NewFacebookDirectory

func NewFacebookDirectory(name string, clientID string, clientSecret string) *Directory

NewFacebookDirectory creates a new directory with a Facebook backed provider

func NewGithubDirectory

func NewGithubDirectory(name string, clientID string, clientSecret string) *Directory

NewGithubDirectory creates a new directory with a GitHub backed provider

func NewGoogleDirectory

func NewGoogleDirectory(name string, clientID string, clientSecret string, redirectURI string) *Directory

NewGoogleDirectory creates a new directory with a Google backed provider

func NewLinkedInDirectory

func NewLinkedInDirectory(name string, clientID string, clientSecret string, redirectURI string) *Directory

NewLinkedInDirectory creates a new directory with a LinkedIn backend provider

func (*Directory) CreateGroup

func (dir *Directory) CreateGroup(group *Group) error

CreateGroup creates a new group in the directory

func (*Directory) GetAccountCreationPolicy

func (dir *Directory) GetAccountCreationPolicy() (*AccountCreationPolicy, error)

GetAccountCreationPolicy loads the directory account creation policy

func (*Directory) GetAccounts

func (r *Directory) GetAccounts(criteria Criteria) (*Accounts, error)

GetAccounts returns all the accounts of the application

See: http://docs.stormpath.com/rest/product-guide/#application-accounts

func (*Directory) GetGroups

func (dir *Directory) GetGroups(criteria Criteria) (*Groups, error)

GetGroups returns all the groups from a directory

func (*Directory) Refresh

func (dir *Directory) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*Directory) RegisterAccount

func (dir *Directory) RegisterAccount(account *Account) error

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

See: http://docs.stormpath.com/rest/product-guide/#accessing-accounts-with-google-authorization-codes-or-an-access-tokens

func (*Directory) Update

func (dir *Directory) Update() error

Update updates the given resource, by doing a POST to the resource Href

type DirectoryCriteria

type DirectoryCriteria struct {
	// contains filtered or unexported fields
}

func MakeDirectoriesCriteria

func MakeDirectoriesCriteria() DirectoryCriteria

func MakeDirectoryCriteria

func MakeDirectoryCriteria() DirectoryCriteria

func (DirectoryCriteria) DescriptionEq

func (c DirectoryCriteria) DescriptionEq(description string) DirectoryCriteria

func (DirectoryCriteria) Limit

func (c DirectoryCriteria) Limit(limit int) Criteria

func (DirectoryCriteria) NameEq

func (DirectoryCriteria) Offset

func (c DirectoryCriteria) Offset(offset int) Criteria

func (DirectoryCriteria) StatusEq

func (c DirectoryCriteria) StatusEq(status string) DirectoryCriteria

func (DirectoryCriteria) ToQueryString

func (c DirectoryCriteria) ToQueryString() string

func (DirectoryCriteria) WithAccountCreationPolicy

func (c DirectoryCriteria) WithAccountCreationPolicy() DirectoryCriteria

func (DirectoryCriteria) WithAccounts

func (c DirectoryCriteria) WithAccounts(pageRequest PageRequest) DirectoryCriteria

func (DirectoryCriteria) WithCustomData

func (c DirectoryCriteria) WithCustomData() DirectoryCriteria

func (DirectoryCriteria) WithGroups

func (c DirectoryCriteria) WithGroups(pageRequest PageRequest) DirectoryCriteria

func (DirectoryCriteria) WithPasswordPolicy

func (c DirectoryCriteria) WithPasswordPolicy() DirectoryCriteria

func (DirectoryCriteria) WithProvider

func (c DirectoryCriteria) WithProvider() DirectoryCriteria

func (DirectoryCriteria) WithTenant

func (c DirectoryCriteria) WithTenant() DirectoryCriteria

type EmailTemplate

type EmailTemplate struct {
	FromEmailAddress string            `json:"fromEmailAddress"`
	FromName         string            `json:"fromName"`
	Subject          string            `json:"subject"`
	HTMLBody         string            `json:"htmlBody"`
	TextBody         string            `json:"textBody"`
	MimeType         string            `json:"mimeType"`
	DefaultModel     map[string]string `json:"defaultModel"`
	// contains filtered or unexported fields
}

EmailTemplate represents an account creation policy email template

func GetEmailTemplate

func GetEmailTemplate(href string) (*EmailTemplate, error)

GetEmailTemplate loads an email template by href

func (*EmailTemplate) Delete

func (r *EmailTemplate) Delete() error

Delete deletes the given account, it wont modify the calling account

func (EmailTemplate) IsCacheable

func (r EmailTemplate) IsCacheable() bool

func (*EmailTemplate) Refresh

func (template *EmailTemplate) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*EmailTemplate) Update

func (template *EmailTemplate) Update() error

Update updates the given resource, by doing a POST to the resource Href

type EmailTemplates

type EmailTemplates struct {
	Items []EmailTemplate `json:"items,omitempty"`
	// contains filtered or unexported fields
}

EmailTemplates represents a collection of EmailTemplate

func (EmailTemplates) GetLimit

func (r EmailTemplates) GetLimit() int

func (EmailTemplates) GetOffset

func (r EmailTemplates) GetOffset() int

func (EmailTemplates) IsCacheable

func (r EmailTemplates) IsCacheable() bool

type Error

type Error struct {
	RequestID        string
	Status           int    `json:"status"`
	Code             int    `json:"code"`
	Message          string `json:"message"`
	DeveloperMessage string `json:"developerMessage"`
	MoreInfo         string `json:"moreInfo"`
	OAuth2Error      string `json:"error"`
}

Error maps a Stormpath API JSON error object which implements Go error interface

func (Error) Error

func (e Error) Error() string

func (Error) String

func (e Error) String() string

type ExpandedJWT

type ExpandedJWT struct {
	Claims    Claims `json:"claims"`
	Header    Header `json:"header"`
	Signature string `json:"signature"`
}

ExpandedJWT represents the OAuth token expanded JWT information

type GrantTypeClientCredentialsTokenClaims

type GrantTypeClientCredentialsTokenClaims struct {
	jwt.StandardClaims
	Scope string `json:"scope,omitempty"`
}

GrantTypeClientCredentialsTokenClaims are the JWT claims use for the client credentials OAuth2 grant type authentication

type GrantTypeStormpathTokenClaims

type GrantTypeStormpathTokenClaims struct {
	jwt.StandardClaims
	Status string `json:"status,omitempty"`
}

GrantTypeStormpathTokenClaims are the JWT claims for a Stormpath OAuth2 authentication using the stormpath_token grant type

type Group

type Group struct {
	Name               string            `json:"name,omitempty"`
	Description        string            `json:"description,omitempty"`
	Status             string            `json:"status,omitempty"`
	Tenant             *Tenant           `json:"tenant,omitempty"`
	Directory          *Directory        `json:"directory,omitempty"`
	AccountMemberships *GroupMemberships `json:"accountMemberships,omitempty"`
	// contains filtered or unexported fields
}

Group represents a Stormpath Group

See: http://docs.stormpath.com/rest/product-guide/#groups

func GetGroup

func GetGroup(href string, criteria Criteria) (*Group, error)

GetGroup loads a group by href and criteria

func NewGroup

func NewGroup(name string) *Group

NewGroup creates a new Group with the given name

func (*Group) GetAccounts

func (r *Group) GetAccounts(criteria Criteria) (*Accounts, error)

GetAccounts returns all the accounts of the application

See: http://docs.stormpath.com/rest/product-guide/#application-accounts

func (*Group) GetGroupAccountMemberships

func (group *Group) GetGroupAccountMemberships(criteria Criteria) (*GroupMemberships, error)

GetGroupAccountMemberships loads the given group memeberships

func (*Group) Refresh

func (group *Group) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*Group) Update

func (group *Group) Update() error

Update updates the given resource, by doing a POST to the resource Href

type GroupCriteria

type GroupCriteria struct {
	// contains filtered or unexported fields
}

func MakeGroupCriteria

func MakeGroupCriteria() GroupCriteria

func MakeGroupMemershipsCriteria

func MakeGroupMemershipsCriteria() GroupCriteria

func MakeGroupsCriteria

func MakeGroupsCriteria() GroupCriteria

func (GroupCriteria) DescriptionEq

func (c GroupCriteria) DescriptionEq(description string) GroupCriteria

func (GroupCriteria) Limit

func (c GroupCriteria) Limit(limit int) Criteria

func (GroupCriteria) NameEq

func (c GroupCriteria) NameEq(name string) GroupCriteria

func (GroupCriteria) Offset

func (c GroupCriteria) Offset(offset int) Criteria

func (GroupCriteria) StatusEq

func (c GroupCriteria) StatusEq(status string) GroupCriteria

func (GroupCriteria) ToQueryString

func (c GroupCriteria) ToQueryString() string

func (GroupCriteria) WithAccounts

func (c GroupCriteria) WithAccounts(pageRequest PageRequest) GroupCriteria

func (GroupCriteria) WithCustomData

func (c GroupCriteria) WithCustomData() GroupCriteria

func (GroupCriteria) WithDirectory

func (c GroupCriteria) WithDirectory() GroupCriteria

func (GroupCriteria) WithTenant

func (c GroupCriteria) WithTenant() GroupCriteria

type GroupMembership

type GroupMembership struct {
	Account *Account `json:"account"`
	Group   *Group   `json:"group"`
	// contains filtered or unexported fields
}

func NewGroupMembership

func NewGroupMembership(accountHref string, groupHref string) *GroupMembership

func (*GroupMembership) Delete

func (r *GroupMembership) Delete() error

Delete deletes the given account, it wont modify the calling account

func (*GroupMembership) GetAccount

func (groupmembership *GroupMembership) GetAccount(criteria Criteria) (*Account, error)

func (*GroupMembership) GetGroup

func (groupmembership *GroupMembership) GetGroup(criteria Criteria) (*Group, error)

func (GroupMembership) IsCacheable

func (r GroupMembership) IsCacheable() bool

type GroupMembershipCriteria

type GroupMembershipCriteria struct {
	// contains filtered or unexported fields
}

func MakeGroupMemershipCriteria

func MakeGroupMemershipCriteria() GroupMembershipCriteria

func (GroupMembershipCriteria) Limit

func (c GroupMembershipCriteria) Limit(limit int) Criteria

func (GroupMembershipCriteria) Offset

func (c GroupMembershipCriteria) Offset(offset int) Criteria

func (GroupMembershipCriteria) ToQueryString

func (c GroupMembershipCriteria) ToQueryString() string

func (GroupMembershipCriteria) WithAccount

func (GroupMembershipCriteria) WithGroup

type GroupMemberships

type GroupMemberships struct {
	Items []GroupMembership `json:"items,omitempty"`
	// contains filtered or unexported fields
}

func (GroupMemberships) GetLimit

func (r GroupMemberships) GetLimit() int

func (GroupMemberships) GetOffset

func (r GroupMemberships) GetOffset() int

func (GroupMemberships) IsCacheable

func (r GroupMemberships) IsCacheable() bool

type Groups

type Groups struct {
	Items []Group `json:"items,omitempty"`
	// contains filtered or unexported fields
}

Groups represent a paged result of groups

func (Groups) GetLimit

func (r Groups) GetLimit() int

func (Groups) GetOffset

func (r Groups) GetOffset() int

func (Groups) IsCacheable

func (r Groups) IsCacheable() bool
type Header struct {
	ALG string `json:"alg"`
	KID string `json:"kid"`
	STT string `json:"stt"`
}

Header represents the expanded JWT header

type IDSiteAssertionTokenClaims

type IDSiteAssertionTokenClaims struct {
	jwt.StandardClaims
	State  string `json:"state,omitempty"`
	Status string `json:"status,omitempty"`
}

IDSiteAssertionTokenClaims are the JWT claims of an Stormpath Assertion type authentication this could originage from an IDSite workflow

type IDSiteOptions

type IDSiteOptions struct {
	Logout      bool
	Path        string
	CallbackURL string
	State       string
}

type LocalCache

type LocalCache struct {
	// contains filtered or unexported fields
}

func NewLocalCache

func NewLocalCache(ttl time.Duration, tti time.Duration) *LocalCache

func (*LocalCache) Count

func (cache *LocalCache) Count() int

Count returns the number of items in the cache (helpful for tracking memory leaks)

func (*LocalCache) Del

func (cache *LocalCache) Del(key string)

func (*LocalCache) Exists

func (cache *LocalCache) Exists(key string) bool

func (*LocalCache) Get

func (cache *LocalCache) Get(key string) []byte

func (*LocalCache) Set

func (cache *LocalCache) Set(key string, data []byte)

type OAuthAccessTokenResult

type OAuthAccessTokenResult OAuthResponse

func (*OAuthAccessTokenResult) GetAccount

func (ar *OAuthAccessTokenResult) GetAccount() *Account

type OAuthBearerAuthenticator

type OAuthBearerAuthenticator Authenticator

OAuthBearerAuthenticator should authenticate OAuth2 bearer tokens only. The token is an access token JWT that has been created by Stormpath. The token may have been created by the client_credential or password_grant flow. This can be determined by looking at the kid property in the header of the JWT. Password grant JWTs will have a kid, but client credential JWTs will not.

func NewOAuthBearerAuthenticator

func NewOAuthBearerAuthenticator(application *Application) OAuthBearerAuthenticator

func (OAuthBearerAuthenticator) Authenticate

func (a OAuthBearerAuthenticator) Authenticate(accessTokenJWT string) (*AuthenticationResult, error)

type OAuthClientCredentialsAuthenticationResult

type OAuthClientCredentialsAuthenticationResult OAuthResponse

func (*OAuthClientCredentialsAuthenticationResult) GetAccount

type OAuthClientCredentialsAuthenticator

type OAuthClientCredentialsAuthenticator struct {
	Authenticator
	ScopeFactory ScopeFactoryFunc
	TTL          time.Duration
}

OAuthClientCredentialsAuthenticator this authenticator accepts an Account's API Key and Secret, and gives back an access token in response. The authenticator should follow the same authentication rules as the BasicAuthenticator. The end-user (account) can request scope, if the scope factory determines that this scope is permitted, then the scope should be added to the access token.

This authenticator is responsible for creating the access token. The Stormpath REST API does not yet provide the client_credential grant on the appplication's /oauth/token endpoint.

func NewOAuthClientCredentialsAuthenticator

func NewOAuthClientCredentialsAuthenticator(application *Application) OAuthClientCredentialsAuthenticator

func (OAuthClientCredentialsAuthenticator) Authenticate

func (a OAuthClientCredentialsAuthenticator) Authenticate(accountAPIKeyID, accountAPIKeySecret, scope string) (*OAuthClientCredentialsAuthenticationResult, error)

type OAuthPasswordAuthenticator

type OAuthPasswordAuthenticator Authenticator

OAuthPasswordAuthenticator this authenticator accepts an account's username and password, and returns an access token response that is obtained by posting the username and password to the application's /oauth/token endpoint with the grant_type=password parameter.

func NewOAuthPasswordAuthenticator

func NewOAuthPasswordAuthenticator(application *Application) OAuthPasswordAuthenticator

func (OAuthPasswordAuthenticator) Authenticate

func (a OAuthPasswordAuthenticator) Authenticate(username, password string) (*OAuthAccessTokenResult, error)

type OAuthPolicy

type OAuthPolicy struct {
	AccessTokenTTL  string `json:"accessTokenTtl,omitempty"`
	RefreshTokenTTL string `json:"refreshTokenTtl,omitempty"`
	// contains filtered or unexported fields
}

OAuthPolicy holds the application related OAuth configuration

func (*OAuthPolicy) Delete

func (r *OAuthPolicy) Delete() error

Delete deletes the given account, it wont modify the calling account

func (OAuthPolicy) IsCacheable

func (r OAuthPolicy) IsCacheable() bool

func (*OAuthPolicy) Update

func (policy *OAuthPolicy) Update() error

Update OAuthPolicy

type OAuthProvider

type OAuthProvider struct {
	ClientID     string `json:"clientId,omitempty"`
	ClientSecret string `json:"clientSecret,omitempty"`
	RedirectURI  string `json:"redirectUri,omitempty"`
}

OAuthProvider represents a generic OAuth2 provider for all the social type directories

type OAuthRefreshTokenAuthenticator

type OAuthRefreshTokenAuthenticator Authenticator

OAuthRefreshTokenAuthenticator this authenticator accepts a previously-issued refresh token and post's it to the application's /oauth/token endpoint with the grant_type=refresh_token parameter. The response is a new access token response.

func NewOAuthRefreshTokenAuthenticator

func NewOAuthRefreshTokenAuthenticator(application *Application) OAuthRefreshTokenAuthenticator

func (OAuthRefreshTokenAuthenticator) Authenticate

func (a OAuthRefreshTokenAuthenticator) Authenticate(refreshToken string) (*OAuthAccessTokenResult, error)

type OAuthRequestAuthenticator

type OAuthRequestAuthenticator struct {
	Authenticator
	ScopeFactory ScopeFactoryFunc
	TTL          time.Duration
}

OAuthRequestAuthenticator should authenticate OAuth2 requests. It will eventually support authenticating all 4 OAuth2 grant types.

Specifically, right now, this class will authenticate OAuth2 access tokens, as well as handle API key for access token exchanges using the OAuth2 client credentials grant type.

func NewOAuthRequestAuthenticator

func NewOAuthRequestAuthenticator(application *Application) OAuthRequestAuthenticator

func (OAuthRequestAuthenticator) Authenticate

type OAuthResponse

type OAuthResponse struct {
	AccessToken              string `json:"access_token"`
	RefreshToken             string `json:"refresh_token,omitempty"`
	TokenType                string `json:"token_type"`
	ExpiresIn                int    `json:"expires_in"`
	StormpathAccessTokenHref string `json:"stormpath_access_token_href,omitempty"`
}

OAuthResponse represents an OAuth2 response from StormPath

type OAuthStormpathTokenAuthenticator

type OAuthStormpathTokenAuthenticator Authenticator

OAuthStormpathTokenAuthenticator this authenticator takes a Stormpath Token JWT and posts it to the application's /oauth/token endpoint, as grant_type=stormpath_token. The result is an OAuthAccessTokenResult.

func NewOAuthStormpathTokenAuthenticator

func NewOAuthStormpathTokenAuthenticator(application *Application) OAuthStormpathTokenAuthenticator

func (OAuthStormpathTokenAuthenticator) Authenticate

func (a OAuthStormpathTokenAuthenticator) Authenticate(stormpathJWT string) (*OAuthAccessTokenResult, error)

type OAuthToken

type OAuthToken struct {
	Account     *Account     `json:"account"`
	Application *Application `json:"application"`
	Tenant      *Tenant      `json:"tenant"`
	JWT         string       `json:"jwt"`
	ExpandedJWT ExpandedJWT  `json:"expandedJwt"`
	// contains filtered or unexported fields
}

OAuthToken represents the Stormpath OAuthToken see: https://docs.stormpath.com/guides/token-management/

func (*OAuthToken) Delete

func (t *OAuthToken) Delete() error

Delete deletes the given OAuthToken

func (OAuthToken) IsCacheable

func (r OAuthToken) IsCacheable() bool

type OAuthTokenCriteria

type OAuthTokenCriteria struct {
	// contains filtered or unexported fields
}

func MakeOAuthTokensCriteria

func MakeOAuthTokensCriteria() OAuthTokenCriteria

func (OAuthTokenCriteria) Limit

func (c OAuthTokenCriteria) Limit(limit int) Criteria

func (OAuthTokenCriteria) Offset

func (c OAuthTokenCriteria) Offset(offset int) Criteria

func (OAuthTokenCriteria) ToQueryString

func (c OAuthTokenCriteria) ToQueryString() string

type OAuthTokens

type OAuthTokens struct {
	Items []OAuthToken `json:"items,omitempty"`
	// contains filtered or unexported fields
}

OAuthTokens collection type for OAuthToken

func (OAuthTokens) GetLimit

func (r OAuthTokens) GetLimit() int

func (OAuthTokens) GetOffset

func (r OAuthTokens) GetOffset() int

func (OAuthTokens) IsCacheable

func (r OAuthTokens) IsCacheable() bool

type PageRequest

type PageRequest struct {
	Limit  int
	Offset int
}

PageRequest contains the limit and offset values for any paginated Stormpath request

type PasswordPolicy

type PasswordPolicy struct {
	ResetTokenTTL              int             `json:"resetTokenTtl,omitempty"`
	ResetEmailStatus           string          `json:"resetEmailStatus,omitempty"`
	ResetSuccessEmailStatus    string          `json:"resetSuccessEmailStatus,omitempty"`
	ResetEmailTemplates        *EmailTemplates `json:"resetEmailTemplates,omitempty"`
	ResetSuccessEmailTemplates *EmailTemplates `json:"resetSuccessEmailTemplates,omitempty"`
	// contains filtered or unexported fields
}

func (*PasswordPolicy) Delete

func (r *PasswordPolicy) Delete() error

Delete deletes the given account, it wont modify the calling account

func (*PasswordPolicy) GetResetEmailTemplates

func (policy *PasswordPolicy) GetResetEmailTemplates() (*EmailTemplates, error)

GetResetEmailTemplates loads the policy ResetEmailTemplates collection and returns it

func (*PasswordPolicy) GetResetSuccessEmailTemplates

func (policy *PasswordPolicy) GetResetSuccessEmailTemplates() (*EmailTemplates, error)

GetResetSuccessEmailTemplates loads the policy ResetSuccessEmailTemplates collection and returns it

func (PasswordPolicy) IsCacheable

func (r PasswordPolicy) IsCacheable() bool

func (*PasswordPolicy) Refresh

func (policy *PasswordPolicy) Refresh() error

Refresh refreshes the resource by doing a GET to the resource href endpoint

func (*PasswordPolicy) Update

func (policy *PasswordPolicy) Update() error

Update updates the given resource, by doing a POST to the resource Href

type Provider

type Provider struct {
	OAuthProvider
	ProviderID string `json:"providerId,omitempty"`
	// contains filtered or unexported fields
}

Provider represents the directory provider (cloud, google, github, facebook or linkedin)

func (*Provider) Delete

func (r *Provider) Delete() error

Delete deletes the given account, it wont modify the calling account

func (Provider) IsCacheable

func (r Provider) IsCacheable() bool

type ProviderData

type ProviderData struct {
	ProviderID  string `json:"providerId"`
	AccessToken string `json:"accessToken,omitempty"`
	Code        string `json:"code,omitempty"`
}

ProviderData represents the especific information needed by the social provider (Google, Github, Faceboo, etc)

type SAMLAssertionTokenClaims

type SAMLAssertionTokenClaims struct {
	jwt.StandardClaims
	State    string `json:"state,omitempty"`
	Status   string `json:"status,omitempty"`
	IsNewSub string `json:"isNewSub,omitempty"`
	IRT      string `json:"irt,omitempty"`
}

SAMLAssertionTokenClaims are the JWT claims of an Stormpath Assertion type authentication this could originage from an SAML workflow

type SAMLAuthenticationTokenClaims

type SAMLAuthenticationTokenClaims struct {
	jwt.StandardClaims
	CallbackURI string `json:"cb_uri,omitempty"`
	State       string `json:"state,omitempty"`
	ASH         string `json:"ash,omitempty"`
	ONK         string `json:"onk,omitempty"`
}

SAMLAuthenticationTokenClaims are the JWT claims needed to start a Stormpath SAML workflow

type SSOTokenClaims

type SSOTokenClaims struct {
	jwt.StandardClaims
	CallbackURI           string `json:"cb_uri,omitempty"`
	Path                  string `json:"path,omitempty"`
	State                 string `json:"state,omitempty"`
	OrganizationNameKey   string `json:"organizationNameKey,omitempty"`
	ShowOrganiztaionField bool   `json:"showOrganiztaionField,omitempty"`
}

SSOTokenClaims are the JWT for initiating an IDSite workflow

see: http://docs.stormpath.com/guides/using-id-site/

type ScopeFactoryFunc

type ScopeFactoryFunc func(string) bool

type SocialAccount

type SocialAccount struct {
	Data ProviderData `json:"providerData"`
}

SocialAccount represents the JSON payload use to create an account for a social backend directory (Google, Facebook, Github, etc)

type StormpathAssertionAuthenticationResult

type StormpathAssertionAuthenticationResult CallbackResult

func (*StormpathAssertionAuthenticationResult) GetAccount

type StormpathAssertionAuthenticator

type StormpathAssertionAuthenticator Authenticator

StormpathAssertionAuthenticator this authenticator will verify the a JWT from an ID Site or SAML callback. It should verify that:

* The token is not expired * The signature can be verified * The claims body does not contain an err property.

func NewStormpathAssertionAuthenticator

func NewStormpathAssertionAuthenticator(application *Application) StormpathAssertionAuthenticator

func (StormpathAssertionAuthenticator) Authenticate

type Tenant

type Tenant struct {
	Name         string        `json:"name,omitempty"`
	Key          string        `json:"key,omitempty"`
	Applications *Applications `json:"applications,omitempty"`
	Directories  *Directories  `json:"directories,omitempty"`
	// contains filtered or unexported fields
}

Tenant represents a Stormpath tennat see http://docs.stormpath.com/rest/product-guide/#tenants

func CurrentTenant

func CurrentTenant() (*Tenant, error)

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

func (tenant *Tenant) CreateDirectory(dir *Directory) error

CreateDirectory creates a new directory for the given tenant

See: http://docs.stormpath.com/rest/product-guide/#tenant-directories

func (*Tenant) DeleteCustomData

func (r *Tenant) DeleteCustomData() error

DeleteCustomData deletes all the resource custom data

See: http://docs.stormpath.com/rest/product-guide/#custom-data

func (*Tenant) GetApplications

func (tenant *Tenant) GetApplications(criteria Criteria) (*Applications, error)

GetApplications returns all the applications for the given tenant

See: http://docs.stormpath.com/rest/product-guide/#tenant-applications

func (*Tenant) GetCustomData

func (r *Tenant) GetCustomData() (CustomData, error)

GetCustomData returns the given resource custom data

See: http://docs.stormpath.com/rest/product-guide/#custom-data

func (*Tenant) GetDirectories

func (tenant *Tenant) GetDirectories(criteria Criteria) (*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 (r *Tenant) UpdateCustomData(customData CustomData) (CustomData, error)

UpdateCustomData sets or updates the given resource custom data

See: http://docs.stormpath.com/rest/product-guide/#custom-data

Directories

Path Synopsis
web

Jump to

Keyboard shortcuts

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