Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(op): Server interface #447

Merged
merged 30 commits into from
Sep 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d6a9c0b
first draft of a new server interface
muhlemmer Sep 4, 2023
cf3a87c
allow any response type
muhlemmer Sep 4, 2023
c340ed9
complete interface docs
muhlemmer Sep 4, 2023
4fcda01
refelct the format from the proposal
muhlemmer Sep 6, 2023
2902a81
intermediate commit with some methods implemented
muhlemmer Sep 8, 2023
2b08c53
implement remaining token grant type methods
muhlemmer Sep 11, 2023
6993769
implement remaining server methods
muhlemmer Sep 11, 2023
f4dac05
error handling
muhlemmer Sep 12, 2023
fe3f98a
rewrite auth request validation
muhlemmer Sep 13, 2023
81d42b0
define handlers, routes
muhlemmer Sep 13, 2023
aae3492
input validation and concrete handlers
muhlemmer Sep 20, 2023
c98291a
check if client credential client is authenticated
muhlemmer Sep 21, 2023
af2d294
copy and modify the routes test for the legacy server
muhlemmer Sep 21, 2023
46839e0
run integration tests against both Server and Provider
muhlemmer Sep 21, 2023
6f45991
remove unuse ValidateAuthRequestV2 function
muhlemmer Sep 22, 2023
57e8b19
unit tests for error handling
muhlemmer Sep 22, 2023
b12bb7a
cleanup tokenHandler
muhlemmer Sep 22, 2023
a88181b
move server routest test
muhlemmer Sep 22, 2023
d27be59
unit test authorize
muhlemmer Sep 22, 2023
b7cbe15
handle client credentials in VerifyClient
muhlemmer Sep 25, 2023
f9a4b82
change code exchange route test
muhlemmer Sep 25, 2023
d17e452
finish http unit tests
muhlemmer Sep 25, 2023
abb0bb0
review server interface docs and spelling
muhlemmer Sep 25, 2023
e9c4940
add withClient unit test
muhlemmer Sep 25, 2023
a49ad31
server options
muhlemmer Sep 25, 2023
c6f6a88
cleanup unused GrantType method
muhlemmer Sep 25, 2023
f6cb47f
resolve typo comments
muhlemmer Sep 27, 2023
af22c1a
make endpoints pointers to enable/disable them
muhlemmer Sep 27, 2023
0200c23
jwt profile base work
livio-a Sep 28, 2023
a1a6c19
jwt: correct the test expect
muhlemmer Sep 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review server interface docs and spelling
  • Loading branch information
muhlemmer committed Sep 25, 2023
commit abb0bb0d09636019badd990dfd11be9371786ea2
26 changes: 12 additions & 14 deletions pkg/op/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@ import (
// the method documentation gives a recommended type which can be used
// directly or extended upon.
type Server interface {
// Health should return a status of "ok" once the Server is listining.
// Health returns a status of "ok" once the Server is listening.
// The recommended Response Data type is [Status].
Health(context.Context, *Request[struct{}]) (*Response, error)

// Ready should return a status of "ok" once all dependecies,
// such as database storage are ready.
// Ready returns a status of "ok" once all dependencies,
// such as database storage, are ready.
// An error can be returned to explain what is not ready.
// The recommended Response Data type is [Status].
Ready(context.Context, *Request[struct{}]) (*Response, error)

// Discovery return the OpenID Provider Configuration Information for this server.
// Discovery returns the OpenID Provider Configuration Information for this server.
// https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig
// The recommended Response Data type is [oidc.DiscoveryConfiguration].
Discovery(context.Context, *Request[struct{}]) (*Response, error)

// Keys serves the JWK set which the client can use verify signatures from the op.
// https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata `jwks_uri` key.
// The recommended Response Data type is [jose.JSOMWebKeySet].
// The recommended Response Data type is [jose.JSONWebKeySet].
Keys(context.Context, *Request[struct{}]) (*Response, error)

// VerifyAuthRequest verifies the Auth Request and
// adds the Client to the request.
//
// When the `request` field is populated with a
// "Request Object" JWT, it needs to be Validated
// and its claims overwrtite any fields in the AuthRequest.
// and its claims overwrite any fields in the AuthRequest.
// If the implementation does not support "Request Object",
// it MUST return an [oidc.ErrRequestNotSupported].
// https://openid.net/specs/openid-connect-core-1_0.html#RequestObject
Expand All @@ -59,8 +59,6 @@ type Server interface {
// authorize endpoint sections (one for each type of flow).
Authorize(context.Context, *ClientRequest[oidc.AuthRequest]) (*Redirect, error)

// AuthorizeCallback? Do we still need it?

// DeviceAuthorization initiates the device authorization flow.
// https://datatracker.ietf.org/doc/html/rfc8628#section-3.1
// The recommended Response Data type is [oidc.DeviceAuthorizationResponse].
Expand All @@ -74,7 +72,7 @@ type Server interface {
VerifyClient(context.Context, *Request[ClientCredentials]) (Client, error)

// CodeExchange returns Tokens after an authorization code
// is obtained in a succesfull Authorize flow.
// is obtained in a successful Authorize flow.
// It is called by the Token endpoint handler when
// grant_type has the value authorization_code
// https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
Expand Down Expand Up @@ -112,7 +110,7 @@ type Server interface {
// DeviceToken handles the OAuth 2.0 Device Authorization Grant
// It is called by the Token endpoint handler when
// grant_type has the value urn:ietf:params:oauth:grant-type:device_code.
// It is typically called in a polling fashion and appropiate errors
// It is typically called in a polling fashion and appropriate errors
// should be returned to signal authorization_pending or access_denied etc.
// https://datatracker.ietf.org/doc/html/rfc8628#section-3.4,
// https://datatracker.ietf.org/doc/html/rfc8628#section-3.5.
Expand Down Expand Up @@ -140,7 +138,7 @@ type Server interface {
EndSession(context.Context, *Request[oidc.EndSessionRequest]) (*Redirect, error)

// mustImpl forces implementations to embed the UnimplementedServer for forward
// compatibilty with the interface.
// compatibility with the interface.
mustImpl()
}

Expand Down Expand Up @@ -173,7 +171,7 @@ func newRequest[T any](r *http.Request, data *T) *Request[T] {
}

// ClientRequest is a Request with a verified client attached to it.
// Methods the recieve this argument may assume the client was authenticated,
// Methods the receive this argument may assume the client was authenticated,
muhlemmer marked this conversation as resolved.
Show resolved Hide resolved
// or verified to be a public client.
type ClientRequest[T any] struct {
*Request[T]
Expand Down Expand Up @@ -215,7 +213,7 @@ func (resp *Response) writeOut(w http.ResponseWriter) {

// Redirect is a special response type which will
// initiate a [http.StatusFound] redirect.
// The Params fielde will be encoded and set to the
// The Params field will be encoded and set to the
// URL's RawQuery field before building the URL.
type Redirect struct {
// Header map will be merged with the
Expand All @@ -236,7 +234,7 @@ func (red *Redirect) writeOut(w http.ResponseWriter, r *http.Request) {

type UnimplementedServer struct{}

// UnimplementedStatusCode is the statuscode returned for methods
// UnimplementedStatusCode is the status code returned for methods
// that are not yet implemented.
// Note that this means methods in the sense of the Go interface,
// and not http methods covered by "501 Not Implemented".
Expand Down