diff options
| author | mo khan <mo@mokhan.ca> | 2022-04-06 15:02:38 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2022-04-06 15:02:38 -0600 |
| commit | 33a05f6cc65ac7d909c671ba79b0676faa6e3284 (patch) | |
| tree | 7e144c5bd2d843f990432c2f2f08f242d8044769 | |
| parent | af6eba8487d6bd43242e887ef4d27b41cac062d0 (diff) | |
link to different flows in spec
| -rwxr-xr-x | src/oidc/bin/01_authz_code (renamed from src/oidc/bin/authz_code) | 0 | ||||
| -rwxr-xr-x | src/oidc/bin/02_token_request (renamed from src/oidc/bin/token_request) | 0 | ||||
| -rw-r--r-- | src/oidc/main.go | 26 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/oidc/bin/authz_code b/src/oidc/bin/01_authz_code index fa96133..fa96133 100755 --- a/src/oidc/bin/authz_code +++ b/src/oidc/bin/01_authz_code diff --git a/src/oidc/bin/token_request b/src/oidc/bin/02_token_request index 48e49e8..48e49e8 100755 --- a/src/oidc/bin/token_request +++ b/src/oidc/bin/02_token_request diff --git a/src/oidc/main.go b/src/oidc/main.go index c996e6a..5da4809 100644 --- a/src/oidc/main.go +++ b/src/oidc/main.go @@ -41,8 +41,15 @@ func handler(w http.ResponseWriter, r *http.Request) { RedirectUri: r.FormValue("redirect_uri"), } if ar.ResponseType == "code" { + // Authorization Code Flow https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth url := fmt.Sprintf("%s?code=example&state=%s", ar.RedirectUri, ar.State) http.Redirect(w, r, url, 302) + } else if ar.ResponseType == "id_token token" || ar.ResponseType == "id_token" { + // Implicit Flow https://openid.net/specs/openid-connect-core-1_0.html#ImplicitFlowAuth + w.WriteHeader(http.StatusNotImplemented) + } else if ar.ResponseType == "code id_token" || ar.ResponseType == "code token" || ar.ResponseType == "code id_token token" { + // Hybrid Flow https://openid.net/specs/openid-connect-core-1_0.html#HybridFlowAuth + w.WriteHeader(http.StatusNotImplemented) } else { w.WriteHeader(http.StatusNotFound) fmt.Fprintf(w, "Not Found\n") @@ -53,16 +60,19 @@ func handler(w http.ResponseWriter, r *http.Request) { Code: r.FormValue("code"), RedirectUri: r.FormValue("redirect_uri"), } - r := &TokenResponse{ - AccessToken: "stateful_token", - TokenType: "Bearer", - RefreshToken: "another_stateful_token", - ExpiresIn: 3600, - IdToken: "JWT", - } - if tr.GrantType == "authorization_code" { + // Authorization Code Flow https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth + r := &TokenResponse{ + AccessToken: "stateful_token", + TokenType: "Bearer", + RefreshToken: "another_stateful_token", + ExpiresIn: 3600, + IdToken: "JWT", + } + w.Header().Set("Content-Type", "application/json") + w.Header().Set("Cache-Control", "no-store") + w.Header().Set("Pragma", "no-cache") fmt.Fprintf(w, `{"access_token": "%s","token_type": "%s","refresh_token": "%s","expires_in": %d,"id_token": "%s"}`, r.AccessToken, r.TokenType, r.RefreshToken, r.ExpiresIn, r.IdToken) } else { w.WriteHeader(http.StatusNotFound) |
