Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAuthorization(ctx context.Context, c echo.Context, scope string) (*settings.DialSettings, error)
- func GetBearerToken(r *http.Request) (string, error)
- func LookupByToken(token string) (*settings.DialSettings, error)
- func NewConfig(opts cloudlib.ProviderConfig) (*cloudlib.Provider, error)
- func NewDefaultProvider() interface{}
- func UpdateConfig(opts cloudlib.ProviderConfig) (*cloudlib.Provider, error)
- func UpdateStore(ds *settings.DialSettings) error
- type AuthProvider
Constants ¶
View Source
const ( TypeAuthProvider cloudlib.ProviderType = 40 // anonymous ScopeAnonymous = "api:anonymous" // this basically means that the Client is unknown // default API scopes ScopeApiRead = "api:read" // that's the very minimum for a proper client ScopeApiWrite = "api:write" ScopeApiEdit = "api:edit" ScopeApiCreate = "api:create" ScopeApiDelete = "api:delete" ScopeApiAdmin = "api:admin" // block access ScopeApiNoAccess = "api:noaccess" )
Variables ¶
View Source
var ( // ErrInternalAuthError indicates that soemthing went wrong with the provider ErrInternalAuthError = errors.New("internal auth error") // ErrInvalidCredentials indicates that the provided credentials did not pass validation ErrInvalidCredentials = errors.New("invalid credentials") // ErrTokenNotFound indicates that the token is not in the store ErrTokenNotFound = errors.New("token not found") // ErrNotAuthorized indicates that the API caller is not authorized ErrNotAuthorized = errors.New("not authorized") ErrAlreadyAuthorized = errors.New("already authorized") // ErrAlreadyInitialized indicates that client is already registered ErrAlreadyInitialized = errors.New("already initialized") // ErrNoToken indicates that no bearer token was provided ErrNoToken = errors.New("no token provided") // ErrTokenExpired indicates that the token is no longer valid ErrTokenExpired = errors.New("token expired") // ErrNoScope indicates that no scope was provided ErrNoScope = errors.New("no scope provided") )
Functions ¶
func CheckAuthorization ¶
func CheckAuthorization(ctx context.Context, c echo.Context, scope string) (*settings.DialSettings, error)
Auth functionallity
CheckAuthorization relies on the presence of a bearer token and validates the matching authorization against a list of requested scopes. If everything checks out, the function returns the authorization or an error otherwise.
func LookupByToken ¶
func LookupByToken(token string) (*settings.DialSettings, error)
func NewConfig ¶ added in v0.3.0
func NewConfig(opts cloudlib.ProviderConfig) (*cloudlib.Provider, error)
func NewDefaultProvider ¶ added in v0.3.0
func NewDefaultProvider() interface{}
a default provider with just an in-memory store
func UpdateConfig ¶ added in v0.3.0
func UpdateConfig(opts cloudlib.ProviderConfig) (*cloudlib.Provider, error)
func UpdateStore ¶
func UpdateStore(ds *settings.DialSettings) error
Types ¶
type AuthProvider ¶ added in v0.3.0
type AuthProvider interface { LookupByToken(token string) (*settings.DialSettings, error) UpdateStore(ds *settings.DialSettings) error }
Click to show internal directories.
Click to hide internal directories.