pwsso

package
v2.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const KeycloakBaseURL = "https://id.pathwar.land"

Variables

View Source
var (
	ErrInvalidLengthPwsso        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPwsso          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupPwsso = fmt.Errorf("proto: unexpected end of group")
)

Functions

func SubjectFromToken

func SubjectFromToken(token *jwt.Token) string

func TestingToken

func TestingToken(t *testing.T) *jwt.Token

func TestingToken2

func TestingToken2(t *testing.T) *jwt.Token

func TestingTransport

func TestingTransport(t *testing.T) http.RoundTripper

func TokenHasRole

func TokenHasRole(token *jwt.Token, expectedRole string) error

func TokenWithClaims

func TokenWithClaims(bearer string, pubkey interface{}, allowUnsafe bool) (*jwt.Token, jwt.MapClaims, error)

Types

type ActionToken

type ActionToken struct {
	Typ   string     `protobuf:"bytes,1,opt,name=typ,proto3" json:"typ,omitempty"`
	Iat   *time.Time `protobuf:"bytes,2,opt,name=iat,proto3,stdtime" json:"iat,omitempty"`
	Exp   *time.Time `protobuf:"bytes,3,opt,name=exp,proto3,stdtime" json:"exp,omitempty"`
	Sub   string     `protobuf:"bytes,4,opt,name=sub,proto3" json:"sub,omitempty"`
	Azp   string     `protobuf:"bytes,5,opt,name=azp,proto3" json:"azp,omitempty"`
	Iss   string     `protobuf:"bytes,6,opt,name=iss,proto3" json:"iss,omitempty"`
	Aud   string     `protobuf:"bytes,7,opt,name=aud,proto3" json:"aud,omitempty"`
	Asid  string     `protobuf:"bytes,8,opt,name=asid,proto3" json:"asid,omitempty"`
	Nonce string     `protobuf:"bytes,9,opt,name=nonce,proto3" json:"nonce,omitempty"`
	// additional keycloak internals
	SessionState string     `protobuf:"bytes,100,opt,name=session_state,json=sessionState,proto3" json:"session_state,omitempty"`
	Scope        string     `protobuf:"bytes,101,opt,name=scope,proto3" json:"scope,omitempty"`
	Nbf          float32    `protobuf:"fixed32,102,opt,name=nbf,proto3" json:"nbf,omitempty"`
	Jti          string     `protobuf:"bytes,103,opt,name=jti,proto3" json:"jti,omitempty"`
	AuthTime     *time.Time `protobuf:"bytes,104,opt,name=auth_time,json=authTime,proto3,stdtime" json:"auth_time,omitempty"`
}

See https://www.keycloak.org/docs/latest/server_development/index.html#_action_token_anatomy

func (*ActionToken) Descriptor

func (*ActionToken) Descriptor() ([]byte, []int)

func (*ActionToken) GetAsid

func (m *ActionToken) GetAsid() string

func (*ActionToken) GetAud

func (m *ActionToken) GetAud() string

func (*ActionToken) GetAuthTime

func (m *ActionToken) GetAuthTime() *time.Time

func (*ActionToken) GetAzp

func (m *ActionToken) GetAzp() string

func (*ActionToken) GetExp

func (m *ActionToken) GetExp() *time.Time

func (*ActionToken) GetIat

func (m *ActionToken) GetIat() *time.Time

func (*ActionToken) GetIss

func (m *ActionToken) GetIss() string

func (*ActionToken) GetJti

func (m *ActionToken) GetJti() string

func (*ActionToken) GetNbf

func (m *ActionToken) GetNbf() float32

func (*ActionToken) GetNonce

func (m *ActionToken) GetNonce() string

func (*ActionToken) GetScope

func (m *ActionToken) GetScope() string

func (*ActionToken) GetSessionState

func (m *ActionToken) GetSessionState() string

func (*ActionToken) GetSub

func (m *ActionToken) GetSub() string

func (*ActionToken) GetTyp

func (m *ActionToken) GetTyp() string

func (*ActionToken) Marshal

func (m *ActionToken) Marshal() (dAtA []byte, err error)

func (*ActionToken) MarshalTo

func (m *ActionToken) MarshalTo(dAtA []byte) (int, error)

func (*ActionToken) MarshalToSizedBuffer

func (m *ActionToken) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ActionToken) ProtoMessage

func (*ActionToken) ProtoMessage()

func (*ActionToken) Reset

func (m *ActionToken) Reset()

func (*ActionToken) Size

func (m *ActionToken) Size() (n int)

func (*ActionToken) String

func (m *ActionToken) String() string

func (*ActionToken) Unmarshal

func (m *ActionToken) Unmarshal(dAtA []byte) error

func (*ActionToken) XXX_DiscardUnknown

func (m *ActionToken) XXX_DiscardUnknown()

func (*ActionToken) XXX_Marshal

func (m *ActionToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ActionToken) XXX_Merge

func (m *ActionToken) XXX_Merge(src proto.Message)

func (*ActionToken) XXX_Size

func (m *ActionToken) XXX_Size() int

func (*ActionToken) XXX_Unmarshal

func (m *ActionToken) XXX_Unmarshal(b []byte) error

type Claims

type Claims struct {
	PreferredUsername string       `protobuf:"bytes,1,opt,name=preferred_username,json=preferredUsername,proto3" json:"preferred_username,omitempty"`
	Email             string       `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	EmailVerified     bool         `protobuf:"varint,3,opt,name=email_verified,json=emailVerified,proto3" json:"email_verified,omitempty"`
	FamilyName        string       `protobuf:"bytes,4,opt,name=family_name,json=familyName,proto3" json:"family_name,omitempty"`
	GivenName         string       `protobuf:"bytes,5,opt,name=given_name,json=givenName,proto3" json:"given_name,omitempty"`
	ActionToken       *ActionToken `protobuf:"bytes,100,opt,name=action_token,json=actionToken,proto3" json:"action_token,omitempty"`
}

func ClaimsFromToken

func ClaimsFromToken(token *jwt.Token) *Claims

func TestingClaims

func TestingClaims(t *testing.T) *Claims

func (*Claims) Descriptor

func (*Claims) Descriptor() ([]byte, []int)

func (*Claims) GetActionToken

func (m *Claims) GetActionToken() *ActionToken

func (*Claims) GetEmail

func (m *Claims) GetEmail() string

func (*Claims) GetEmailVerified

func (m *Claims) GetEmailVerified() bool

func (*Claims) GetFamilyName

func (m *Claims) GetFamilyName() string

func (*Claims) GetGivenName

func (m *Claims) GetGivenName() string

func (*Claims) GetPreferredUsername

func (m *Claims) GetPreferredUsername() string

func (*Claims) Marshal

func (m *Claims) Marshal() (dAtA []byte, err error)

func (*Claims) MarshalTo

func (m *Claims) MarshalTo(dAtA []byte) (int, error)

func (*Claims) MarshalToSizedBuffer

func (m *Claims) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Claims) ProtoMessage

func (*Claims) ProtoMessage()

func (*Claims) Reset

func (m *Claims) Reset()

func (*Claims) Size

func (m *Claims) Size() (n int)

func (*Claims) String

func (m *Claims) String() string

func (*Claims) Unmarshal

func (m *Claims) Unmarshal(dAtA []byte) error

func (*Claims) XXX_DiscardUnknown

func (m *Claims) XXX_DiscardUnknown()

func (*Claims) XXX_Marshal

func (m *Claims) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Claims) XXX_Merge

func (m *Claims) XXX_Merge(src proto.Message)

func (*Claims) XXX_Size

func (m *Claims) XXX_Size() int

func (*Claims) XXX_Unmarshal

func (m *Claims) XXX_Unmarshal(b []byte) error

type Client

type Client interface {
	TokenWithClaims(bearer string) (*jwt.Token, jwt.MapClaims, error)
	Whoami(token string) (map[string]interface{}, error)
	Logout(token string) error
}

func New

func New(publicKey string, realm string, opts Opts) (Client, error)

func TestingSSO

func TestingSSO(t *testing.T, logger *zap.Logger) Client

type Opts

type Opts struct {
	AllowUnsafe bool
	Logger      *zap.Logger
	ClientID    string

	ClientSecret string
	Realm        string
	TokenFile    string
	Pubkey       string
}

func NewOpts

func NewOpts() Opts

NewOpts returns sane default values for development

func (*Opts) ApplyDefaults

func (opts *Opts) ApplyDefaults()

Jump to

Keyboard shortcuts

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