ciba

package module
v0.0.0-...-f732497 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 10 Imported by: 1

README

go-ciba

OpenID Connect CIBA flow client for golang.

Usage

package main

import (
	"context"
	"fmt"
	"github.com/okzk/go-ciba"
)

func main() {
	client := ciba.NewClient(
		"https://example.com",          // issuer
		"https://example.com/bc-authn", // backchannel_authentication_endpoint
		"https://example.com/token",    // token_endpoint
		"openid",                       // scope
		"sample_client",                // client_id
		"xxxxxxxxxxxxxxxxxxxxx",        // client_secret
	)

	ctx := context.Background()
	token, err := client.Authenticate(ctx, ciba.LoginHint("alice"))
	if err != nil {
		panic(err)
	}

	claims := token.Claims()
	fmt.Println(claims["sub"])
}

Limitations

  • Support poll mode only.
  • Support client_secret_basic only.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationParam

type AuthenticationParam func(values url.Values)

func ACRValues

func ACRValues(acrValues string) AuthenticationParam

func BindingMessage

func BindingMessage(bindingMessage string) AuthenticationParam

func IDTokenHint

func IDTokenHint(idTokenHint string) AuthenticationParam

func LoginHint

func LoginHint(loginHint string) AuthenticationParam

func LoginHintToken

func LoginHintToken(loginHintToken string) AuthenticationParam

func RequestedExpiry

func RequestedExpiry(requestedExpiry int) AuthenticationParam

func UserCode

func UserCode(userCode string) AuthenticationParam

type AuthnResponse

type AuthnResponse struct {
	AuthReqID string `json:"auth_req_id,omitempty"`
	ExpiresIn int    `json:"expires_in,omitempty"`
	Interval  int    `json:"interval,omitempty"`

	Error string `json:"error,omitempty"`
}

type CIBAError

type CIBAError struct {
	Status    int
	ErrorCode string
}

func (*CIBAError) Error

func (e *CIBAError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(issuer, bcAuthnEndpoint, tokenEndpoint, scope, clientID, clientSecret string) *Client

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context, params ...AuthenticationParam) (*Token, error)

type Token

type Token struct {
	IDToken      string `json:"id_token"`
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	ExpiresIn    int    `json:"expires_in,omitempty"`

	Error string `json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*Token) Claims

func (t *Token) Claims() jwt.MapClaims

Jump to

Keyboard shortcuts

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