Skip to content

Commit 68ceb25

Browse files
authored
Readme content (#22)
1 parent 7300e07 commit 68ceb25

File tree

6 files changed

+76
-27
lines changed

6 files changed

+76
-27
lines changed

README.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
# Project
1+
# Microsoft Authentication Library (MSAL) Extensions for Go
22

3-
> This repo has been populated by an initial template to help get you started. Please
4-
> make sure to update the content to build a great experience for community-building.
5-
6-
As the maintainer of this project, please make a few updates:
7-
8-
- Improving this README.MD file to provide a great experience
9-
- Updating SUPPORT.MD with content about this project's support experience
10-
- Understanding the security reporting process in SECURITY.MD
11-
- Remove this section from the README
3+
This repository contains extension modules for [Microsoft Authentication Library (MSAL) for Go](https://github.com/AzureAD/microsoft-authentication-library-for-go):
4+
- [github.com/AzureAD/microsoft-authentication-extensions-for-go/cache](https://github.com/AzureAD/microsoft-authentication-extensions-for-go/tree/dev/cache): cross-platform persistent caching for MSAL public clients
125

136
## Contributing
147

@@ -23,11 +16,3 @@ provided by the bot. You will only need to do this once across all repos using o
2316
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
2417
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
2518
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
26-
27-
## Trademarks
28-
29-
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
30-
trademarks or logos is subject to and must follow
31-
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
32-
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
33-
Any use of third-party trademarks or logos are subject to those third-party's policies.

cache/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Microsoft Authentication Library (MSAL) Extensions for Go
2+
3+
This module contains a persistent cache for [Microsoft Authentication Library (MSAL) for Go](https://github.com/AzureAD/microsoft-authentication-library-for-go) public client applications such as CLI tools. It isn't recommended for web applications or RPC APIs, in which it can cause scaling and performance problems.
4+
5+
The cache supports encrypted storage on Linux, macOS and Windows. The encryption facility depends on the platform:
6+
- Linux: [libsecret](https://wiki.gnome.org/Projects/Libsecret) (used as a DBus Secret Service client)
7+
- macOS: keychain
8+
- Windows: data protection API (DPAPI)
9+
10+
See the `accessor` package for more details. The `file` package has a plaintext storage provider to use when encryption isn't possible.
11+
12+
> Plaintext storage is dangerous. Bearer tokens are not cryptographically bound to a machine and can be stolen. In particular, the refresh token can be used to get access tokens for many resources.
13+
> It's important to warn end-users before falling back to plaintext. End-users should ensure they store the tokens in a secure location (e.g. encrypted disk) and must understand they are responsible for their safety.
14+
15+
## Installation
16+
17+
```sh
18+
go get -u github.com/AzureAD/microsoft-authentication-extensions-for-go/cache
19+
```
20+
21+
## Contributing
22+
23+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
24+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
25+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
26+
27+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
28+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
29+
provided by the bot. You will only need to do this once across all repos using our CLA.
30+
31+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
32+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
33+
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

cache/accessor/linux.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ type attribute struct {
115115

116116
type option func(*Storage) error
117117

118-
// WithAttribute adds an attribute to the secret schema representing the cache.
119-
// Storage supports up to 2 attributes.
118+
// WithAttribute adds an attribute to the schema representing the cache.
119+
// [Storage] supports up to 2 attributes.
120120
func WithAttribute(name, value string) option {
121121
return func(s *Storage) error {
122122
if len(s.attributes) == 2 {
@@ -127,17 +127,17 @@ func WithAttribute(name, value string) option {
127127
}
128128
}
129129

130-
// WithLabel sets a label on the secret schema representing the cache. The default label is "MSALCache".
130+
// WithLabel sets a label on the schema representing the cache. The default label is "MSALCache".
131131
func WithLabel(label string) option {
132132
return func(s *Storage) error {
133133
s.label = label
134134
return nil
135135
}
136136
}
137137

138-
// Storage uses libsecret to store data by a DBus Secret Service such as GNOME Keyring or KDE Wallet. The Service must
139-
// be unlocked before Storage can read or write data to it. Unlocking typically requires user interaction, and some
140-
// systems may be unable to unlock the Service in a headless environment such as an SSH session.
138+
// Storage uses libsecret to store data with a DBus Secret Service such as GNOME Keyring or KDE Wallet. The Service
139+
// must be unlocked before Storage can access it. Unlocking typically requires user interaction, and some systems may
140+
// be unable to unlock the Service in a headless environment such as an SSH session.
141141
type Storage struct {
142142
// attributes are key/value pairs on the secret schema
143143
attributes []attribute

cache/accessor/windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (s *Storage) Read(context.Context) ([]byte, error) {
5858
}
5959

6060
// Write stores data in the file, creating the file if it doesn't exist.
61-
func (s *Storage) Write(ctx context.Context, data []byte) error {
61+
func (s *Storage) Write(_ context.Context, data []byte) error {
6262
s.m.Lock()
6363
defer s.m.Unlock()
6464

cache/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type locker interface {
3030
}
3131

3232
// Cache caches authentication data in external storage, using a file lock to coordinate
33-
// access to it with other processes.
33+
// access with other processes.
3434
type Cache struct {
3535
// a provides read/write access to storage
3636
a accessor.Accessor
@@ -47,7 +47,7 @@ type Cache struct {
4747
}
4848

4949
// New is the constructor for Cache. "p" is the path to a file used to track when stored
50-
// data changes. Export will create this file and any directories in its path which don't
50+
// data changes. [Cache.Export] will create this file and any directories in its path which don't
5151
// already exist.
5252
func New(a accessor.Accessor, p string) (*Cache, error) {
5353
lock, err := lock.New(p+".lockfile", retryDelay)

cache/example_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
package cache_test
5+
6+
import (
7+
"github.com/AzureAD/microsoft-authentication-extensions-for-go/cache"
8+
"github.com/AzureAD/microsoft-authentication-extensions-for-go/cache/accessor"
9+
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/public"
10+
)
11+
12+
// This example shows how to configure an MSAL public client to store data in a peristent, encrypted cache.
13+
func Example() {
14+
// On Linux and macOS, "s" is an arbitrary name identifying the cache.
15+
// On Windows, it's the path to a file in which to store cache data.
16+
s := "..."
17+
a, err := accessor.New(s)
18+
if err != nil {
19+
// TODO: handle error
20+
}
21+
c, err := cache.New(a, s)
22+
if err != nil {
23+
// TODO: handle error
24+
}
25+
app, err := public.New("client-id", public.WithCache(c))
26+
if err != nil {
27+
// TODO: handle error
28+
}
29+
30+
_ = app
31+
}

0 commit comments

Comments
 (0)