Categorygithub.com/jarias/stormpath-sdk-go
modulepackage
0.0.0-20170306172927-a4587787d37e
Repository: https://github.com/jarias/stormpath-sdk-go.git
Documentation: pkg.go.dev

# README


Due to this announcement https://stormpath.com/blog/stormpaths-new-path 
this project is no longer maintain

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, please follow this sample workflow, make sure you work out of the develop branch.

  • Fork
  • Clone git clone YOUR_USERNAME/stormpath-sdk-go
  • Checkout develop branch git checkout -t origin/develop
  • Create a feature branch git checkout -b YOUR_FEATURE_OR_BUG_FIX
  • Create a PR to jarias/develop hub pull-request -b jarias/stormpath-sdk-go:develop

Please make sure you add tests ;)

Development requirements:

  • Go 1.7+
  • 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.

# Packages

No description provided by the author

# Functions

Authenticate generates the proper authentication header for the SAuthc1 algorithm use by Stormpath.
CreateApplication creates a new application in Stormpath.It also passes the createDirectory param as true so the default directory would be created and mapped to the application.
CreateDirectory creates a new directory for the given tenant See: http://docs.stormpath.com/rest/product-guide/#tenant-directories.
CurrentTenant retrieves the Tenant associated with the current API key.
GetAccount fetches an account by href and criteria.
GetAPIKey retrives an APIKey resource by href and optional criteria.
GetApplication loads an application by href.It can optionally have its attributes expanded depending on the ApplicationCriteria value.
GetClient returns the configured client.
GetDirectory loads a directory by href and criteria.
GetEmailTemplate loads an email template by href.
GetGroup loads a group by href and criteria.
GetOrganization loads an organization by href and criteria.
No description provided by the author
Init initializes the underlying client that communicates with Stormpath.
No description provided by the author
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.
LoadConfiguration loads the configuration from the default locations.
LoadConfigurationWithCreds loads the configuration from the default localtions but with custom Stormpath credentials.
MakeAccountCriteria creates a new AccountCriteria for a single Account resource.
MakeAccountsCriteria creates a new AccountCriteria for a AccountList resource.
MakeAPIKeyCriteria creates a default APIKeyCriteria for a single APIKey resource.
MakeAPIKeysCriteria creates a default APIKeyCriteria for a APIKeys collection resource.
MakeApplicationAccountStoreMappingCriteria creates a default ApplicationAccountStoreMappingCriteria for a single ApplicationAccountStoreMapping resource.
MakeApplicationAccountStoreMappingsCriteria creates a default ApplicationAccountStoreMappingCriteria for a ApplicationAccountStoreMappings collection resource.
MakeApplicationCriteria an empty ApplicationCriteria for an application.
MakeApplicationsCriteria an empty ApplicationCriteria for an applications collection.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MakeOrganizationAccountStoreMappingCriteria creates a default OrganizationAccountStoreMappingCriteria for a single OrganizationAccountStoreMapping resource.
MakeOrganizationAccountStoreMappingsCriteria creates a default OrganizationAccountStoreMappingCriteria for a OrganizationAccountStoreMappings collection resource.
No description provided by the author
No description provided by the author
NewAccount returns a pointer to an Account with the minimum data required.
NewApplicationAccountStoreMapping creates a new account store mapping for the Application resource.
NewBasicAuthenticator returns a BasicAuthenticator for the given application.
NewDirectory creates a new directory with the given name.
NewFacebookDirectory creates a new directory with a Facebook backed provider.
NewGithubDirectory creates a new directory with a GitHub backed provider.
NewGoogleDirectory creates a new directory with a Google backed provider.
NewGroup creates a new Group with the given name.
No description provided by the author
NewLinkedInDirectory creates a new directory with a LinkedIn backend provider.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewOAuthRequestAuthenticator creates a new OAuthRequestAuthenticator for a given Application.
No description provided by the author
NewOrganization creates a new organization.
NewOrganizationAccountStoreMapping creates a new account mapping for the Organization resource.
NewPageRequest is a conviniece constructor for a PageRequest.
No description provided by the author
No description provided by the author
VerifyEmailToken verifies an email verification token associated with an account See: http://docs.stormpath.com/rest/product-guide/#account-verify-email.

# Constants

No description provided by the author
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
No description provided by the author
No description provided by the author
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
No description provided by the author
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
No description provided by the author
No description provided by the author
SAuthc1 algorithm constants.
No description provided by the author
SAuthc1 algorithm constants.
No description provided by the author
No description provided by the author
No description provided by the author
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
No description provided by the author
No description provided by the author
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
SAuthc1 algorithm constants.
No description provided by the author
SAuthc1 algorithm constants.
No description provided by the author
No description provided by the author
SAuthc1 algorithm constants.
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
Logger library wide logger.

# Structs

AccessTokenClaims are the JWT for a Stormpath OAuth2 access token.
Account represents an Stormpath account object See: http://docs.stormpath.com/rest/product-guide/#accounts.
AccountCreationPolicy represents a directory account creation policy object See: http://docs.stormpath.com/rest/product-guide/#directory-account-creation-policy.
AccountCriteria represents the Criteria type for accounts.
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).
Accounts represents a paged result of Account objects See: http://docs.stormpath.com/rest/product-guide/#accounts-collectionResource.
APIKey represents an Account key id/secret pair resource See: https://docs.stormpath.com/rest/product-guide/latest/reference.html#account-api-keys.
APIKeyCriteria represents the criteria type for the APIKey resource.
APIKeys represents a collection of APIKey resources.
Application is resource in Stormpath contains information about any real-world software that communicates with Stormpath via REST APIs.
ApplicationAccountStoreMapping represents an Stormpath account store mapping See: https://docs.stormpath.com/rest/product-guide/latest/reference.html#account-store-mapping.
ApplicationAccountStoreMappingCriteria is the criteria type for the ApplicationAccountStoreMapping resource.
ApplicationAccountStoreMappings represents a pages result of account store mappings See: http://docs.stormpath.com/rest/product-guide/#collectionResource-account-store-mappings.
ApplicationCriteria rerpresents the criteria object for an application or an applications collection.
Applications is the collection resource of applications.
AuthenticationResult base authentication result for all authenticators.
Authenticator is the base authenticator type See https://github.com/stormpath/stormpath-sdk-spec/blob/master/specifications/authenticators.md.
CallbackResult is the parsed IDSite callback JWT token information and an optional account if the tocken contain one.
Claims represents the expanded JWT claims.
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 itand don't cache any response.
ClientConfiguration representd the overall SDK configuration options.
Directories represnets a paged result of directories.
Directory represents a Stormpath directory object See: http://docs.stormpath.com/rest/product-guide/#directories.
No description provided by the author
EmailTemplate represents an account creation policy email template.
EmailTemplates represents a collection of EmailTemplate.
Error maps a Stormpath API JSON error object which implements Go error interface.
ExpandedJWT represents the OAuth token expanded JWT information.
GrantTypeClientCredentialsTokenClaims are the JWT claims use for the client credentials OAuth2 grant typeauthentication.
GrantTypeStormpathTokenClaims are the JWT claims for a Stormpath OAuth2 authentication usingthe stormpath_token grant type.
Group represents a Stormpath Group See: http://docs.stormpath.com/rest/product-guide/#groups.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Groups represent a paged result of groups.
Header represents the expanded JWT header.
IDSiteAssertionTokenClaims are the JWT claims of an Stormpath Assertion type authenticationthis could originage from an IDSite workflow.
IDSiteOptions represents the posible options to generate an new IDSite URL.
No description provided by the author
OAuthClientCredentialsAuthenticator this authenticator accepts an Account's API Key and Secret, and gives back an access token in response.
OAuthPolicy holds the application related OAuth configuration.
OAuthProvider represents a generic OAuth2 provider for all the social type directories.
OAuthRequestAuthenticator should authenticate OAuth2 requests.
OAuthResponse represents an OAuth2 response from StormPath.
OAuthToken represents the Stormpath OAuthToken see: https://docs.stormpath.com/guides/token-management/.
No description provided by the author
OAuthTokens collection type for OAuthToken.
Organization represnts the Stormpath organization resource, use for multitenancy.
OrganizationAccountStoreMapping represents an Stormpath account store mapping for an Organization resource See: https://docs.stormpath.com/rest/product-guide/latest/reference.html?organization-account-store-mapping-operations.
OrganizationAccountStoreMappingCriteria is the criteria type for OrganizationAccountStoreMapping.
OrganizationAccountStoreMappings represents a collection of OrganizationAccountStoreMapping.
No description provided by the author
Organizations represents a paged result or applications.
PageRequest contains the limit and offset values for any paginated Stormpath request.
No description provided by the author
Provider represents the directory provider (cloud, google, github, facebook or linkedin).
ProviderData represents the especific information needed by the social provider (Google, Github, Faceboo, etc).
SAMLAssertionTokenClaims are the JWT claims of an Stormpath Assertion type authenticationthis could originage from an SAML workflow.
SAMLAuthenticationTokenClaims are the JWT claims needed to start a Stormpath SAML workflow.
SocialAccount represents the JSON payload use to create an account for a social backend directory(Google, Facebook, Github, etc).
SSOTokenClaims are the JWT for initiating an IDSite workflow see: http://docs.stormpath.com/guides/using-id-site/.
Tenant When you sign up for Stormpath, a private data space is created for you.

# Interfaces

AuthResult is implemented by any authentication result for any of the posible authenticators to retrievethe authentication result account.
Cache is a base interface for any cache provider.
Cacheable determines if the implementor should be cached or not.

# Type aliases

BasicAuthenticator will authenticate the API Key and Secret of a Stormpath Account object.
CustomData represents Stormpath's custom data resouce.
OAuthAccessTokenResult is the default OAuth response.
OAuthBearerAuthenticator should authenticate OAuth2 bearer tokens only.
OAuthClientCredentialsAuthenticationResult is the authentication result for the OAuthClientCredentialsAuthenticator.
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.
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.
OAuthStormpathTokenAuthenticator this authenticator takes a Stormpath Token JWT and posts it to the application's /oauth/token endpoint, as grant_type=stormpath_token.
ScopeFactoryFunc defines a function to valide scope for the cient credentials OAuth authentication.
StormpathAssertionAuthenticationResult is the authentication result for the StormpathAssertionAuthenticator.
StormpathAssertionAuthenticator this authenticator will verify the a JWT from an ID Site or SAML callback.