oauth2Utils

package
v0.0.0-...-e2c1db5 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OAUTH2_ACCESS_TABLE_NAME                 = "oauth2_access"
	OAUTH2_ACCESS_AUTHORIZE_DATA_COLUMN_NAME = "AuthorizeData"
	OAUTH2_ACCESS_ACCESS_DATA_COLUMN_NAME    = "AccessData"
	OAUTH2_ACCESS_ACCESS_TOKEN_COLUMN_NAME   = "AccessToken"
	OAUTH2_ACCESS_REFRESH_TOKEN_COLUMN_NAME  = "RefreshToken"
)
View Source
const (
	OAUTH2_AUTHORIZE_TABLE_NAME         = "oauth2_authorize"
	OAUTH2_AUTHORIZE_CLIENT_COLUMN_NAME = "Client"
	OAUTH2_AUTHORIZE_CODE_COLUMN_NAME   = "Code"
)
View Source
const (
	E_INVALID_AUTH_DATA                          = "access_invalid_auth_data"
	E_ACCESS_EMPTY_USER_ERROR                    = "access_disallow_empty_user"
	E_ACCESS_DATA_MISSING_USER                   = "access_data_missing_user"
	E_INSUFFICIENT_SCOPE                         = "access_data_insufficient_scope"
	E_EMAIL_DOES_NOT_EXIST_OR_PASSWORD_INCORRECT = "email_not_exist_or_incorrect_password"
)

Variables

View Source
var OsinServerObject *osin.Server

Functions

func AddPredefinedOAuthClient

func AddPredefinedOAuthClient(client *OAuth2Client_NonDb)

func AuthorizeAndServeNewAccessTokenWithRouter

func AuthorizeAndServeNewAccessTokenWithRouter(ctx *context.Context, cookieSecurityContext *CookieSecurityContext, authUserProvider iAuthUserProvider, setCookies bool, successfulOutputHandler outputHandlerFunc)

func CheckRequiredScopeSatisfied

func CheckRequiredScopeSatisfied(responseWriter http.ResponseWriter, authorizedScope string, functionToCheckRequiredScope StringPredicate)

func ConvertIntoOsinAccess

func ConvertIntoOsinAccess(authorize *OAuth2Access) *osin.AccessData

func ConvertIntoOsinAuthorize

func ConvertIntoOsinAuthorize(authorize *OAuth2Authorize) *osin.AuthorizeData

func ConvertIntoOsinClient

func ConvertIntoOsinClient(client *OAuth2Client_NonDb) *osin.DefaultClient

func CreateFieldsToLoadInOAuth2Access

func CreateFieldsToLoadInOAuth2Access(loadAuthorizeData, loadAccessData bool) *RelatedFieldsToLoad

func ExtractAccessTokenFromSuccessfulResponseData

func ExtractAccessTokenFromSuccessfulResponseData(responseData osin.ResponseData) (string, bool)

func InitOsinServerObject

func InitOsinServerObject()

func InjectCodeIntoFormIfWasPassedViaAuthorizationHeader

func InjectCodeIntoFormIfWasPassedViaAuthorizationHeader(request *http.Request)

func OverwriteOsinResponseErrorWithOwn

func OverwriteOsinResponseErrorWithOwn(osinResponse *osin.Response)

func OverwriteOsinResponseErrorWithOwn_SpecifyErrorKey

func OverwriteOsinResponseErrorWithOwn_SpecifyErrorKey(osinResponse *osin.Response, errorKey string)

func PanicInvalidAuthData

func PanicInvalidAuthData()

func ScopeHasRequiredScope

func ScopeHasRequiredScope(actualScopesCSV, requiredScope string) bool

func ServeAccessTokenWithRouter

func ServeAccessTokenWithRouter(ctx *context.Context)

func TempCookieSecret

func TempCookieSecret(randsPlusPassword string) string

Types

type AuthorizedContext

type AuthorizedContext struct {
	User  IExpectedUser
	Scope string
	// contains filtered or unexported fields
}

func CreateAuthorizedContext

func CreateAuthorizedContext(user IExpectedUser, scope string, accessToken string) *AuthorizedContext

func GetAuthorizedContextFromAccessToken

func GetAuthorizedContextFromAccessToken(osinResponse *osin.Response, ctx *context.Context) *AuthorizedContext

func (*AuthorizedContext) GetAccessToken

func (this *AuthorizedContext) GetAccessToken() string

func (*AuthorizedContext) GetCookie

func (this *AuthorizedContext) GetCookie(router tmpGetSecureCookieInterface, name string) (string, bool)

func (*AuthorizedContext) SetCookie

func (this *AuthorizedContext) SetCookie(router tmpSetSecureCookieInterface, name, value string)

type IExpectedUser

type IExpectedUser interface {
	GetRands() string
	GetPassword() string
	GetId() int64
	IAmAUser()
}

type OAuth2Access

type OAuth2Access struct {
	Id            int64
	ClientId      int64            //Client        *OAuth2Client    `orm:"rel(fk)"`
	UserId        int64            //Store the ID so we can keep it generic
	AuthorizeData *OAuth2Authorize `orm:"rel(fk);null"`
	AccessData    *OAuth2Access    `orm:"rel(fk);on_delete(set_null);null"` //Previous access data, for refresh token. It must only set_null on_delete otherwise the workflow fails
	AccessToken   string
	RefreshToken  string
	ExpiresIn     int32
	Scope         string `orm:"type(text)"`
	RedirectUri   string
	CreatedAt     time.Time

	User IExpectedUser `orm:"-"` //For now lets not allow NULL users as if we want to create our own 'bot' accessing the data, we can also create a user for it. And perhaps have a boolean flag for user entities called 'bot'?
}

func ConvertFromOsinAccess

func ConvertFromOsinAccess(osinAccess *osin.AccessData) *OAuth2Access

func (*OAuth2Access) Delete

func (this *OAuth2Access) Delete(ormContext *OrmContext)

func (*OAuth2Access) Insert

func (this *OAuth2Access) Insert(ormContext *OrmContext)

func (*OAuth2Access) ReadUsingAccessToken

func (this *OAuth2Access) ReadUsingAccessToken(ormContext *OrmContext, accessToken string, loadRelatedSettings *RelatedFieldsToLoad) bool

func (*OAuth2Access) ReadUsingID

func (this *OAuth2Access) ReadUsingID(ormContext *OrmContext, id int64, loadRelatedSettings *RelatedFieldsToLoad)

func (*OAuth2Access) ReadUsingRefreshToken

func (this *OAuth2Access) ReadUsingRefreshToken(ormContext *OrmContext, refreshToken string, loadRelatedSettings *RelatedFieldsToLoad) bool

func (*OAuth2Access) TableEngine

func (u *OAuth2Access) TableEngine() string

func (*OAuth2Access) TableIndex

func (u *OAuth2Access) TableIndex() [][]string

func (*OAuth2Access) TableName

func (u *OAuth2Access) TableName() string

func (*OAuth2Access) TableUnique

func (u *OAuth2Access) TableUnique() [][]string

type OAuth2Authorize

type OAuth2Authorize struct {
	Id          int64
	ClientId    int64  //Client        *OAuth2Client    `orm:"rel(fk)"`
	Code        string //The authorization code
	ExpiresIn   int32
	Scope       string `orm:"type(text)"`
	RedirectUri string
	State       string
	CreatedAt   time.Time
}

func ConvertFromOsinAuthorize

func ConvertFromOsinAuthorize(osinAuthorize *osin.AuthorizeData) *OAuth2Authorize

func (*OAuth2Authorize) Delete

func (this *OAuth2Authorize) Delete(ormContext *OrmContext)

func (*OAuth2Authorize) Insert

func (this *OAuth2Authorize) Insert(ormContext *OrmContext)

func (*OAuth2Authorize) ReadUsingCode

func (this *OAuth2Authorize) ReadUsingCode(ormContext *OrmContext, code string, loadRelatedSettings *RelatedFieldsToLoad) bool

func (*OAuth2Authorize) ReadUsingID

func (this *OAuth2Authorize) ReadUsingID(ormContext *OrmContext, id int64, loadRelatedSettings *RelatedFieldsToLoad)

func (*OAuth2Authorize) TableEngine

func (u *OAuth2Authorize) TableEngine() string

func (*OAuth2Authorize) TableIndex

func (u *OAuth2Authorize) TableIndex() [][]string

func (*OAuth2Authorize) TableName

func (u *OAuth2Authorize) TableName() string

func (*OAuth2Authorize) TableUnique

func (u *OAuth2Authorize) TableUnique() [][]string

type OAuth2Client_NonDb

type OAuth2Client_NonDb struct {
	Id                int64 //Do not get confused with the ClientId field which is a string
	ClientId          string
	ClientSecret      string
	RedirectUri       string
	ClientDisplayName string
}

func GetClientUsingClientId

func GetClientUsingClientId(clientId string) (*OAuth2Client_NonDb, bool)

func GetClientUsingId

func GetClientUsingId(id int64) (*OAuth2Client_NonDb, bool)

type OAuth2Storage

type OAuth2Storage struct {
}

func NewOAuth2Storage

func NewOAuth2Storage() *OAuth2Storage

func (*OAuth2Storage) Clone

func (s *OAuth2Storage) Clone() osin.Storage

func (*OAuth2Storage) Close

func (s *OAuth2Storage) Close()

func (*OAuth2Storage) GetClient

func (s *OAuth2Storage) GetClient(clientId string) (returnClient osin.Client, returnErr error)

func (*OAuth2Storage) LoadAccess

func (s *OAuth2Storage) LoadAccess(accessToken string) (data *osin.AccessData, returnErr error)

func (*OAuth2Storage) LoadAuthorize

func (s *OAuth2Storage) LoadAuthorize(code string) (data *osin.AuthorizeData, returnErr error)

func (*OAuth2Storage) LoadRefresh

func (s *OAuth2Storage) LoadRefresh(refreshToken string) (data *osin.AccessData, returnErr error)

func (*OAuth2Storage) RemoveAccess

func (s *OAuth2Storage) RemoveAccess(accessToken string) (returnErr error)

func (*OAuth2Storage) RemoveAuthorize

func (s *OAuth2Storage) RemoveAuthorize(code string) (returnErr error)

func (*OAuth2Storage) RemoveRefresh

func (s *OAuth2Storage) RemoveRefresh(refreshToken string) (returnErr error)

func (*OAuth2Storage) SaveAccess

func (s *OAuth2Storage) SaveAccess(data *osin.AccessData) (returnErr error)

func (*OAuth2Storage) SaveAuthorize

func (s *OAuth2Storage) SaveAuthorize(data *osin.AuthorizeData) (returnErr error)

type OsinAuthorizeError

type OsinAuthorizeError struct {
	ErrorCode   string
	ErrorString string
}

type StringPredicate

type StringPredicate func(string) bool

Jump to

Keyboard shortcuts

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