Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
📝 update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0q committed Feb 6, 2023
1 parent d6b28f0 commit 5e2415d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

traq-oauth2 provides support for OAuth2 authentication in [traQ](https://github.com/traPtitech/traQ)

## Features

- [Authorization Code Flow](https://www.rfc-editor.org/rfc/rfc6749#section-1.3.1)
- Only this flow is supported in traQ.
- [Proof Key for Code Exchange](https://www.rfc-editor.org/rfc/rfc7636)
- PKCE is supported in traQ.
- Few dependencies
- traq-oauth2 only depends on [golang.org/x/oauth2](https://pkg.go.dev/golang.org/x/oauth2) and standard libraries.

## Installation

```bash
Expand Down
6 changes: 3 additions & 3 deletions pkce.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// GenerateCodeVerifier generates a code verifier.
// Ref: https://datatracker.ietf.org/doc/html/rfc7636#section-4.1
// Ref: https://www.rfc-editor.org/rfc/rfc7636#section-4.1
func GenerateCodeVerifier() (string, error) {
b := make([]byte, 32)
if _, err := rand.Read(b); err != nil {
Expand Down Expand Up @@ -41,7 +41,7 @@ func (m CodeChallengeMethod) String() string {
}

// GenerateCodeChallenge generates the code challenge from the code verifier.
// Ref: https://datatracker.ietf.org/doc/html/rfc7636#section-4.2
// Ref: https://www.rfc-editor.org/rfc/rfc7636#section-4.2
func (m CodeChallengeMethod) GenerateCodeChallenge(codeVerifier string) (string, error) {
switch m {
case CodeChallengePlain:
Expand All @@ -61,7 +61,7 @@ func WithCodeChallenge(codeChallenge string) oauth2.AuthCodeOption {

// WithCodeChallengeMethod sets the code_challenge_method parameter.
// The default value is "plain".
// If you want to use "S256", use WithCodeChallengeMethod(traqoauth2.CodeChallenge).
// If you want to use "S256", use WithCodeChallengeMethod(traqoauth2.CodeChallengeS256).
func WithCodeChallengeMethod(codeChallengeMethod CodeChallengeMethod) oauth2.AuthCodeOption {
return oauth2.SetAuthURLParam("code_challenge_method", codeChallengeMethod.String())
}
Expand Down

0 comments on commit 5e2415d

Please sign in to comment.