File: ops.go

package info (click to toggle)
golang-github-azuread-microsoft-authentication-library-for-go 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: makefile: 4
file content (56 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/*
Package ops provides operations to various backend services using REST clients.

The REST type provides several clients that can be used to communicate to backends.
Usage is simple:

	rest := ops.New()

	// Creates an authority client and calls the UserRealm() method.
	userRealm, err := rest.Authority().UserRealm(ctx, authParameters)
	if err != nil {
		// Do something
	}
*/
package ops

import (
	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/accesstokens"
	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority"
	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/internal/comm"
	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/wstrust"
)

// HTTPClient represents an HTTP client.
// It's usually an *http.Client from the standard library.
type HTTPClient = comm.HTTPClient

// REST provides REST clients for communicating with various backends used by MSAL.
type REST struct {
	client *comm.Client
}

// New is the constructor for REST.
func New(httpClient HTTPClient) *REST {
	return &REST{client: comm.New(httpClient)}
}

// Authority returns a client for querying information about various authorities.
func (r *REST) Authority() authority.Client {
	return authority.Client{Comm: r.client}
}

// AccessTokens returns a client that can be used to get various access tokens for
// authorization purposes.
func (r *REST) AccessTokens() accesstokens.Client {
	return accesstokens.Client{Comm: r.client}
}

// WSTrust provides access to various metadata in a WSTrust service. This data can
// be used to gain tokens based on SAML data using the client provided by AccessTokens().
func (r *REST) WSTrust() wstrust.Client {
	return wstrust.Client{Comm: r.client}
}