yorcoidc

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 4

README

orch-service-yorc-oidc-client

OpenID connect client used by Yorc LEXIS plugins.

Acknowledgement

This code repository is a result / contains results of the LEXIS project. The project has received funding from the European Union’s Horizon 2020 Research and Innovation programme (2014-2020) under grant agreement No. 825532.

Usage

Installation
go get github.com/lexis-project/yorcoidc
Importing
 import "github.com/lexis-project/yorcoidc"
Get a Client
 client := yorcoidc.GetClient(yorcDeploymentID, url, clientID, clientSecret, realm)

Features

// Client is the client interface to AAI service
type Client interface {
	// ExchangeToken exchanges a token to get an access and a refresh token for this client
	ExchangeToken(ctx context.Context, accessToken string) (string, string, error)
	// IsAccessTokenValid checks if an access token is still valid
	IsAccessTokenValid(ctx context.Context, accessToken string) (bool, error)
	// RefreshToken refreshes the access token
	RefreshToken(ctx context.Context) (string, string, error)
	// GetAccessToken returns the access token
	GetAccessToken() (string, error)
	// GetRefreshToken returns the refresh token
	GetRefreshToken() (string, error)
	// GetUserInfo returns info on the user (name, attributes, etc..)
	GetUserInfo(ctx context.Context, accessToken string) (UserInfo, error)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// ExchangeToken exchanges a token to get an access and a refresh token for this client
	ExchangeToken(ctx context.Context, accessToken string) (string, string, error)
	// IsAccessTokenValid checks if an access token is still valid
	IsAccessTokenValid(ctx context.Context, accessToken string) (bool, error)
	// RefreshToken refreshes the access token
	RefreshToken(ctx context.Context) (string, string, error)
	// GetAccessToken returns the access token
	GetAccessToken() (string, error)
	// GetRefreshToken returns the refresh token
	GetRefreshToken() (string, error)
	// GetUserInfo returns info on the user (name, attributes, etc..)
	GetUserInfo(ctx context.Context, accessToken string) (UserInfo, error)
}

Client is the client interface to AAI service

func GetClient

func GetClient(deploymentID, url, clientID, clientSecret, realm string) Client

GetClient returns a client of the Authentication and Authorization Infrastructure service

type UserInfo

type UserInfo struct {
	Sub               string                         `json:"sub,omitempty"`
	Name              string                         `json:"name,omitempty"`
	GivenName         string                         `json:"given_name,omitempty"`
	FamilyName        string                         `json:"family_name,omitempty"`
	MiddleName        string                         `json:"middle_name,omitempty"`
	Nickname          string                         `json:"nickname,omitempty"`
	PreferredUsername string                         `json:"preferred_username,omitempty"`
	Profile           string                         `json:"profile,omitempty"`
	Picture           string                         `json:"picture,omitempty"`
	Website           string                         `json:"website,omitempty"`
	Email             string                         `json:"email,omitempty"`
	Gender            string                         `json:"gender,omitempty"`
	ZoneInfo          string                         `json:"zoneinfo,omitempty"`
	Locale            string                         `json:"locale,omitempty"`
	PhoneNumber       string                         `json:"phone_number,omitempty"`
	Attributes        map[string][]map[string]string `json:"attributes,omitempty"`
}

UserInfo provides details on the user info in an acess token

func (UserInfo) GetName

func (u UserInfo) GetName() string

Jump to

Keyboard shortcuts

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