adal

package module
v0.0.0-...-7b2d913 Latest Latest
Warning

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

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

README

go-ADAL

Build Status Code Climate

unofficial Active Directory Authentication Library for go.

Installation

go get github.com/orisano/go-adal

How to Use

package main

import (
	"context"
	"io"
	"log"
	"os"
	
	"github.com/orisano/go-adal"
)

const (
	tenant = "common"
	resource = "resource.example"
	clientID = "xxxxxxxxxxxxxxxxx"
	clientSecret = "xxxxxxxxxxxxxxxxx"
)

func main() {
	ac, err := adal.NewAuthenticationContext(tenant)
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	client, err := ac.Client(ctx, resource, clientID, clientSecret)
	if err != nil {
		log.Fatal(err)
	}
	resp, err := client.Get("http://api.example/v1/resource")
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
	
	io.Copy(os.Stdout, resp.Body)
}

Author

Nao Yonashiro (@orisano)

License

MIT

Documentation

Index

Constants

View Source
const (
	WorldWideAuthority = "login.microsoftonline.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationContext

type AuthenticationContext struct {
	Authority *Authority
}

func NewAuthenticationContext

func NewAuthenticationContext(tenant string, opts ...Option) (*AuthenticationContext, error)

func (*AuthenticationContext) Client

func (a *AuthenticationContext) Client(ctx context.Context, resource, clientID, clientSecret string) (*http.Client, error)

type Authority

type Authority struct {
	URL    *url.URL
	Host   string
	Tenant string
	// contains filtered or unexported fields
}

func NewAuthority

func NewAuthority(urlStr string, validateAuthority bool) (*Authority, error)

func (*Authority) AuthorityURL

func (a *Authority) AuthorityURL() string

func (*Authority) DeviceURL

func (a *Authority) DeviceURL() string

func (*Authority) IsADFSAuthority

func (a *Authority) IsADFSAuthority() bool

func (*Authority) TokenURL

func (a *Authority) TokenURL() string

func (*Authority) Validate

func (a *Authority) Validate(httpClient *http.Client) error

func (*Authority) Validated

func (a *Authority) Validated() bool

type Option

type Option func(*options)

func SetAuthorityHost

func SetAuthorityHost(authorityHost string) Option

func ValidateAuthority

func ValidateAuthority() Option

Jump to

Keyboard shortcuts

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