revauthaad

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

Authentication with Azure Active Directory(AAD)

======

#Usage: Include module in Revel Application file: conf/app.conf

module.revauthaad=github.com/chengkun-kang/rev-auth-aad

Include module in Revel Application file: conf/routes

module:revauthaad

Incude revel config variables in Revel Application file conf/app.conf

aad.tenant.id=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx
aad.app.client.id=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx
aad.app.client.secret=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx
aad.account.primary.domain=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
aad.cloud.instance=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx          # default: https://login.microsoftonline.com
aad.api.users.path=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx          # default: https://graph.microsoft.com/v1.0/users/
aad.api.public.scopes=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx       # default: User.Read
aad.api.credential.scopes=xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxx   # default: https://graph.microsoft.com/.default
app.logout.redirect.url=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx         # default: /login

The Azure AD Cloud Instance options include;

https://login.microsoftonline.com/ for Azure public cloud
https://login.microsoftonline.us/ for Azure US government
https://login.microsoftonline.de/ for Azure AD Germany
https://login.partner.microsoftonline.cn/common for Azure AD China operated by 21Vianet

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireCredentialToken

func AcquireCredentialToken() (string, error)

func AcquirePublicToken

func AcquirePublicToken(account, password string) (string, error)

func InitAAD

func InitAAD()

InitAAD reading AAD configuration

func InitCredentialClient

func InitCredentialClient() (*msgraphsdk.GraphServiceClient, error)

func InitPublicClient

func InitPublicClient(account, password string) (*msgraphsdk.GraphServiceClient, error)

func QueryAndSave

func QueryAndSave(account string) (*models.User, error)

func QueryMailAndSave

func QueryMailAndSave(email string) (*models.User, error)

func QueryUserPhotoById

func QueryUserPhotoById(userId, token string) string

func QueryUserPhotoByName

func QueryUserPhotoByName(username, token string) string

Types

type AuthReply

type AuthReply struct {
	IsAuthenticated bool
	Error           string
	Account         string
	Name            string
	First           string
	Last            string
	Email           string
	Depart          string
	Avatar          string
}

func AuthenticateByClientCredentials

func AuthenticateByClientCredentials(account string) *AuthReply

func AuthenticatePublicClient

func AuthenticatePublicClient(account, password string) *AuthReply

Authenticate do auth and return Auth object including user information and lognin success or not Required Delegated Permission: User.Read, and Grant admin consent as this is a Daemon web api. account could be the pricipal user name in AAD or mail of login user

type QueryReply

type QueryReply struct {
	NotExist bool
	Error    string
	Account  string
	Name     string
	First    string
	Last     string
	Email    string
	Depart   string
	Avatar   string
}

func Query

func Query(userIdentity string) *QueryReply

func QueryMail

func QueryMail(emailAddress string) *QueryReply

Directories

Path Synopsis
app
lib

Jump to

Keyboard shortcuts

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