Documentation ¶
Overview ¶
Package auth provides the various service clients for working with authentication.
Package auth is a generated protocol buffer package.
It is generated from these files:
auth.proto
It has these top-level messages:
TokenGenerateRequest TokenGenerateResponse TokenCheckRequest TokenCheckResponse UserProfileRequest UserProfileResponse AuthProfile
Index ¶
- Constants
- Variables
- func RegisterTokenHandler(s server.Server, hdlr TokenHandler, opts ...server.HandlerOption)
- func RegisterUserHandler(s server.Server, hdlr UserHandler, opts ...server.HandlerOption)
- type AuthProfile
- type Token
- type TokenCheckRequest
- type TokenCheckResponse
- type TokenClient
- type TokenGenerateRequest
- type TokenGenerateResponse
- type TokenHandler
- type User
- type UserClient
- type UserHandler
- type UserProfileRequest
- type UserProfileResponse
Constants ¶
View Source
const (
// JWT is the name of the auth service that works with jwt tokens.
JWT = "org.sugr.micro.test.auth.jwt"
)
Variables ¶
View Source
var ( // SecretKey is the secret key used by auth service for encrypting their // tokens. SecretKey = []byte("secret-key") )
Functions ¶
func RegisterTokenHandler ¶
func RegisterTokenHandler(s server.Server, hdlr TokenHandler, opts ...server.HandlerOption)
func RegisterUserHandler ¶
func RegisterUserHandler(s server.Server, hdlr UserHandler, opts ...server.HandlerOption)
Types ¶
type AuthProfile ¶
type AuthProfile struct { // User is the user name. User string `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"` // Name is the full name of the user. Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` }
AuthProfile
func (*AuthProfile) Descriptor ¶
func (*AuthProfile) Descriptor() ([]byte, []int)
func (*AuthProfile) ProtoMessage ¶
func (*AuthProfile) ProtoMessage()
func (*AuthProfile) Reset ¶
func (m *AuthProfile) Reset()
func (*AuthProfile) String ¶
func (m *AuthProfile) String() string
type Token ¶
type Token struct {
TokenHandler
}
func (*Token) Check ¶
func (h *Token) Check(ctx context.Context, in *TokenCheckRequest, out *TokenCheckResponse) error
func (*Token) Generate ¶
func (h *Token) Generate(ctx context.Context, in *TokenGenerateRequest, out *TokenGenerateResponse) error
type TokenCheckRequest ¶
type TokenCheckRequest struct { // Auth is the authentication token to check. Auth string `protobuf:"bytes,1,opt,name=auth" json:"auth,omitempty"` }
TokenCheckRequest is the request data for checking an authentication token for validity.
func (*TokenCheckRequest) Descriptor ¶
func (*TokenCheckRequest) Descriptor() ([]byte, []int)
func (*TokenCheckRequest) ProtoMessage ¶
func (*TokenCheckRequest) ProtoMessage()
func (*TokenCheckRequest) Reset ¶
func (m *TokenCheckRequest) Reset()
func (*TokenCheckRequest) String ¶
func (m *TokenCheckRequest) String() string
type TokenCheckResponse ¶
type TokenCheckResponse struct { // Valid will be true if the token is valid. Valid bool `protobuf:"varint,1,opt,name=valid" json:"valid,omitempty"` // Expired will be true if the token is no longer valid due to it being too // old. Expired bool `protobuf:"varint,2,opt,name=expired" json:"expired,omitempty"` // User is the user for which the authentication token was generated. User string `protobuf:"bytes,3,opt,name=user" json:"user,omitempty"` }
TokenCheckResponse is the result of the validation request.
func (*TokenCheckResponse) Descriptor ¶
func (*TokenCheckResponse) Descriptor() ([]byte, []int)
func (*TokenCheckResponse) ProtoMessage ¶
func (*TokenCheckResponse) ProtoMessage()
func (*TokenCheckResponse) Reset ¶
func (m *TokenCheckResponse) Reset()
func (*TokenCheckResponse) String ¶
func (m *TokenCheckResponse) String() string
type TokenClient ¶
type TokenClient interface { // Generate generates an auth token. Generate(ctx context.Context, in *TokenGenerateRequest, opts ...client.CallOption) (*TokenGenerateResponse, error) // Check tests the auth string for validity. Check(ctx context.Context, in *TokenCheckRequest, opts ...client.CallOption) (*TokenCheckResponse, error) }
func NewTokenClient ¶
func NewTokenClient(serviceName string, c client.Client) TokenClient
type TokenGenerateRequest ¶
type TokenGenerateRequest struct { // User is the desired username. User string `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"` // Pass is the password for the user. Pass string `protobuf:"bytes,2,opt,name=pass" json:"pass,omitempty"` }
TokenGenerateRequest is the request data for generating an authentication token.
func (*TokenGenerateRequest) Descriptor ¶
func (*TokenGenerateRequest) Descriptor() ([]byte, []int)
func (*TokenGenerateRequest) ProtoMessage ¶
func (*TokenGenerateRequest) ProtoMessage()
func (*TokenGenerateRequest) Reset ¶
func (m *TokenGenerateRequest) Reset()
func (*TokenGenerateRequest) String ¶
func (m *TokenGenerateRequest) String() string
type TokenGenerateResponse ¶
type TokenGenerateResponse struct { // Exists will be true if the user exists Exists bool `protobuf:"varint,1,opt,name=exists" json:"exists,omitempty"` // Auth is the authentication token. Auth string `protobuf:"bytes,2,opt,name=auth" json:"auth,omitempty"` }
TokenGenerateResponse is the result of the authentication token generation.
func (*TokenGenerateResponse) Descriptor ¶
func (*TokenGenerateResponse) Descriptor() ([]byte, []int)
func (*TokenGenerateResponse) ProtoMessage ¶
func (*TokenGenerateResponse) ProtoMessage()
func (*TokenGenerateResponse) Reset ¶
func (m *TokenGenerateResponse) Reset()
func (*TokenGenerateResponse) String ¶
func (m *TokenGenerateResponse) String() string
type TokenHandler ¶
type TokenHandler interface { // Generate generates an auth token. Generate(context.Context, *TokenGenerateRequest, *TokenGenerateResponse) error // Check tests the auth string for validity. Check(context.Context, *TokenCheckRequest, *TokenCheckResponse) error }
type User ¶
type User struct {
UserHandler
}
func (*User) Profile ¶
func (h *User) Profile(ctx context.Context, in *UserProfileRequest, out *UserProfileResponse) error
type UserClient ¶
type UserClient interface { // UserProfile returns a user profile. Profile(ctx context.Context, in *UserProfileRequest, opts ...client.CallOption) (*UserProfileResponse, error) }
func NewUserClient ¶
func NewUserClient(serviceName string, c client.Client) UserClient
type UserHandler ¶
type UserHandler interface { // UserProfile returns a user profile. Profile(context.Context, *UserProfileRequest, *UserProfileResponse) error }
type UserProfileRequest ¶
type UserProfileRequest struct { // Auth is the authentication token. Auth string `protobuf:"bytes,1,opt,name=auth" json:"auth,omitempty"` }
UserProfileRequest is the request data for getting a user's profile.
func (*UserProfileRequest) Descriptor ¶
func (*UserProfileRequest) Descriptor() ([]byte, []int)
func (*UserProfileRequest) ProtoMessage ¶
func (*UserProfileRequest) ProtoMessage()
func (*UserProfileRequest) Reset ¶
func (m *UserProfileRequest) Reset()
func (*UserProfileRequest) String ¶
func (m *UserProfileRequest) String() string
type UserProfileResponse ¶
type UserProfileResponse struct { // Exists is true if the user exists. Exists bool `protobuf:"varint,1,opt,name=exists" json:"exists,omitempty"` // Profile is the profile data for the user. Profile *AuthProfile `protobuf:"bytes,2,opt,name=profile" json:"profile,omitempty"` }
UserProfileResponse is the response data from a user profile request.
func (*UserProfileResponse) Descriptor ¶
func (*UserProfileResponse) Descriptor() ([]byte, []int)
func (*UserProfileResponse) GetProfile ¶
func (m *UserProfileResponse) GetProfile() *AuthProfile
func (*UserProfileResponse) ProtoMessage ¶
func (*UserProfileResponse) ProtoMessage()
func (*UserProfileResponse) Reset ¶
func (m *UserProfileResponse) Reset()
func (*UserProfileResponse) String ¶
func (m *UserProfileResponse) String() string
Click to show internal directories.
Click to hide internal directories.