auth_backend

package module
v0.0.0-...-4c58bcd Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: BSD-2-Clause Imports: 7 Imported by: 1

README

go-edx-openid-auth

Documentation

Index

Constants

View Source
const (
	// URL_AUTHORIZATION used to request an authorization
	URL_AUTHORIZATION = "/oauth2/authorize"
	// URL_ACCESS_TOKEN used to get a new access token
	URL_ACCESS_TOKEN = "/oauth2/access_token"
	// URL_USER_INFO used to retrieve current user information
	URL_USER_INFO = "/oauth2/user_info/"
	// URL_REDIRECT used as parameters when requesting an authorization as redirect uri
	URL_REDIRECT = "/complete/edx-oidc/"
)

Variables

This section is empty.

Functions

func RandomToken

func RandomToken(l int) string

RandomToken generate a random string that will be used as state

func Scopes

func Scopes() []string

Scopes return a default scopes for authentication

Types

type Backend

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

Backend is the main part of auth_backend. It stores oauth2.Config, app and edx url configuration

func Init

func Init(client_id, client_secret, app_url, edx_url string) *Backend

Init to initialize a new backend authentication

func (*Backend) Authenticate

func (backend *Backend) Authenticate(receivedState string, values url.Values) (UserInfo, error)

Authenticate is callback handler when receiving redirection from edx site after successfully login

func (*Backend) GetAuthorizationURL

func (backend *Backend) GetAuthorizationURL(state string) string

GetAuthorizationURL return authentication url based on given state

type UserInfo

type UserInfo struct {
	TrackingID uint   `json:"user_tracking_id"`
	Email      string `json:"email"`
	FamilyName string `json:"family_name"`
	GivenName  string `json:"given_name"`
	Locale     string `json:"locale"`
	Name       string `json:"name'`
	Username   string `json:"preferred_username"`
	Sub        string `json:"sub"`
}

UserInfo stored user information from user endpoint edx

Directories

Path Synopsis
examples
gin

Jump to

Keyboard shortcuts

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