feat: added OIDC discovery

This commit is contained in:
Wyatt Johnson
2018-10-23 15:27:23 -06:00
parent 3b6f3c9ea8
commit 0bb64f1d97
8 changed files with 121 additions and 18 deletions
@@ -1,13 +1,24 @@
import { isNull, omitBy } from "lodash";
import TenantContext from "talk-server/graph/tenant/context";
import { GQLSettingsInput } from "talk-server/graph/tenant/schema/__generated__/types";
import {
GQLDiscoverOIDCConfigurationInput,
GQLOIDCConfiguration,
GQLSettingsInput,
} from "talk-server/graph/tenant/schema/__generated__/types";
import { Tenant } from "talk-server/models/tenant";
import { regenerateSSOKey, update } from "talk-server/services/tenant";
import {
discoverOIDCConfiguration,
regenerateSSOKey,
update,
} from "talk-server/services/tenant";
export default ({ mongo, redis, tenantCache, tenant }: TenantContext) => ({
update: (input: GQLSettingsInput): Promise<Tenant | null> =>
update(mongo, redis, tenantCache, tenant, omitBy(input, isNull)),
regenerateSSOKey: (): Promise<Tenant | null> =>
regenerateSSOKey(mongo, redis, tenantCache, tenant),
discoverOIDCConfiguration: (
input: GQLDiscoverOIDCConfigurationInput
): Promise<GQLOIDCConfiguration> => discoverOIDCConfiguration(input.issuer),
});
@@ -51,6 +51,10 @@ const Mutation: GQLMutationTypeResolver<void> = {
settings: await ctx.mutators.Settings.regenerateSSOKey(),
clientMutationId: input.clientMutationId,
}),
discoverOIDCConfiguration: async (source, { input }, ctx) => ({
configuration: await ctx.mutators.Settings.discoverOIDCConfiguration(input),
clientMutationId: input.clientMutationId,
}),
};
export default Mutation;
@@ -1900,6 +1900,41 @@ type RegenerateSSOKeyPayload {
clientMutationId: String!
}
##################
## discoverOIDCConfiguration
##################
input DiscoverOIDCConfigurationInput {
"""
"""
issuer: String!
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
type OIDCConfiguration {
authorizationURL: String
tokenURL: String
jwksURI: String
}
type DiscoverOIDCConfigurationPayload {
"""
configuration was the discovered configuration for the OpenID Connect server
given the provided issuer.
"""
configuration: OIDCConfiguration
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
##################
## Mutation
##################
@@ -1929,6 +1964,10 @@ type Mutation {
regenerateSSOKey(input: RegenerateSSOKeyInput!): RegenerateSSOKeyPayload
@auth(roles: [ADMIN])
discoverOIDCConfiguration(
input: DiscoverOIDCConfigurationInput!
): DiscoverOIDCConfigurationPayload @auth(roles: [ADMIN])
"""
createCommentReaction will create a Reaction authored by the current logged in
User on a Comment.