mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-06-12 14:30:18 +00:00
295 lines
7.4 KiB
Go
295 lines
7.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: oidc_queries.sql
|
|
|
|
package postgres
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createOIDCConsent = `-- name: CreateOIDCConsent :one
|
|
INSERT INTO "oidc_consent" (
|
|
"uuid",
|
|
"client_id",
|
|
"scopes"
|
|
) VALUES (
|
|
$1, $2, $3
|
|
)
|
|
RETURNING uuid, client_id, scopes, created_at, updated_at
|
|
`
|
|
|
|
type CreateOIDCConsentParams struct {
|
|
UUID string
|
|
ClientID string
|
|
Scopes string
|
|
}
|
|
|
|
func (q *Queries) CreateOIDCConsent(ctx context.Context, arg CreateOIDCConsentParams) (OidcConsent, error) {
|
|
row := q.db.QueryRowContext(ctx, createOIDCConsent, arg.UUID, arg.ClientID, arg.Scopes)
|
|
var i OidcConsent
|
|
err := row.Scan(
|
|
&i.UUID,
|
|
&i.ClientID,
|
|
&i.Scopes,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createOIDCSession = `-- name: CreateOIDCSession :one
|
|
INSERT INTO "oidc_sessions" (
|
|
"sub",
|
|
"access_token_hash",
|
|
"refresh_token_hash",
|
|
"scope",
|
|
"client_id",
|
|
"token_expires_at",
|
|
"refresh_token_expires_at",
|
|
"nonce",
|
|
"userinfo_json"
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9
|
|
)
|
|
RETURNING sub, access_token_hash, refresh_token_hash, scope, client_id, token_expires_at, refresh_token_expires_at, nonce, userinfo_json
|
|
`
|
|
|
|
type CreateOIDCSessionParams struct {
|
|
Sub string
|
|
AccessTokenHash string
|
|
RefreshTokenHash string
|
|
Scope string
|
|
ClientID string
|
|
TokenExpiresAt int64
|
|
RefreshTokenExpiresAt int64
|
|
Nonce string
|
|
UserinfoJson string
|
|
}
|
|
|
|
func (q *Queries) CreateOIDCSession(ctx context.Context, arg CreateOIDCSessionParams) (OidcSession, error) {
|
|
row := q.db.QueryRowContext(ctx, createOIDCSession,
|
|
arg.Sub,
|
|
arg.AccessTokenHash,
|
|
arg.RefreshTokenHash,
|
|
arg.Scope,
|
|
arg.ClientID,
|
|
arg.TokenExpiresAt,
|
|
arg.RefreshTokenExpiresAt,
|
|
arg.Nonce,
|
|
arg.UserinfoJson,
|
|
)
|
|
var i OidcSession
|
|
err := row.Scan(
|
|
&i.Sub,
|
|
&i.AccessTokenHash,
|
|
&i.RefreshTokenHash,
|
|
&i.Scope,
|
|
&i.ClientID,
|
|
&i.TokenExpiresAt,
|
|
&i.RefreshTokenExpiresAt,
|
|
&i.Nonce,
|
|
&i.UserinfoJson,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteExpiredOIDCSessions = `-- name: DeleteExpiredOIDCSessions :exec
|
|
DELETE FROM "oidc_sessions"
|
|
WHERE "token_expires_at" < $1 AND "refresh_token_expires_at" < $2
|
|
`
|
|
|
|
type DeleteExpiredOIDCSessionsParams struct {
|
|
TokenExpiresAt int64
|
|
RefreshTokenExpiresAt int64
|
|
}
|
|
|
|
func (q *Queries) DeleteExpiredOIDCSessions(ctx context.Context, arg DeleteExpiredOIDCSessionsParams) error {
|
|
_, err := q.db.ExecContext(ctx, deleteExpiredOIDCSessions, arg.TokenExpiresAt, arg.RefreshTokenExpiresAt)
|
|
return err
|
|
}
|
|
|
|
const deleteOIDCConsentByUUID = `-- name: DeleteOIDCConsentByUUID :exec
|
|
DELETE FROM "oidc_consent"
|
|
WHERE "uuid" = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteOIDCConsentByUUID(ctx context.Context, uuid string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteOIDCConsentByUUID, uuid)
|
|
return err
|
|
}
|
|
|
|
const deleteOIDCSessionBySub = `-- name: DeleteOIDCSessionBySub :exec
|
|
DELETE FROM "oidc_sessions"
|
|
WHERE "sub" = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteOIDCSessionBySub(ctx context.Context, sub string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteOIDCSessionBySub, sub)
|
|
return err
|
|
}
|
|
|
|
const getOIDCConsentByUUID = `-- name: GetOIDCConsentByUUID :one
|
|
SELECT uuid, client_id, scopes, created_at, updated_at FROM "oidc_consent"
|
|
WHERE "uuid" = $1
|
|
`
|
|
|
|
func (q *Queries) GetOIDCConsentByUUID(ctx context.Context, uuid string) (OidcConsent, error) {
|
|
row := q.db.QueryRowContext(ctx, getOIDCConsentByUUID, uuid)
|
|
var i OidcConsent
|
|
err := row.Scan(
|
|
&i.UUID,
|
|
&i.ClientID,
|
|
&i.Scopes,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOIDCSessionByAccessTokenHash = `-- name: GetOIDCSessionByAccessTokenHash :one
|
|
SELECT sub, access_token_hash, refresh_token_hash, scope, client_id, token_expires_at, refresh_token_expires_at, nonce, userinfo_json FROM "oidc_sessions"
|
|
WHERE "access_token_hash" = $1
|
|
`
|
|
|
|
func (q *Queries) GetOIDCSessionByAccessTokenHash(ctx context.Context, accessTokenHash string) (OidcSession, error) {
|
|
row := q.db.QueryRowContext(ctx, getOIDCSessionByAccessTokenHash, accessTokenHash)
|
|
var i OidcSession
|
|
err := row.Scan(
|
|
&i.Sub,
|
|
&i.AccessTokenHash,
|
|
&i.RefreshTokenHash,
|
|
&i.Scope,
|
|
&i.ClientID,
|
|
&i.TokenExpiresAt,
|
|
&i.RefreshTokenExpiresAt,
|
|
&i.Nonce,
|
|
&i.UserinfoJson,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOIDCSessionByRefreshTokenHash = `-- name: GetOIDCSessionByRefreshTokenHash :one
|
|
SELECT sub, access_token_hash, refresh_token_hash, scope, client_id, token_expires_at, refresh_token_expires_at, nonce, userinfo_json FROM "oidc_sessions"
|
|
WHERE "refresh_token_hash" = $1
|
|
`
|
|
|
|
func (q *Queries) GetOIDCSessionByRefreshTokenHash(ctx context.Context, refreshTokenHash string) (OidcSession, error) {
|
|
row := q.db.QueryRowContext(ctx, getOIDCSessionByRefreshTokenHash, refreshTokenHash)
|
|
var i OidcSession
|
|
err := row.Scan(
|
|
&i.Sub,
|
|
&i.AccessTokenHash,
|
|
&i.RefreshTokenHash,
|
|
&i.Scope,
|
|
&i.ClientID,
|
|
&i.TokenExpiresAt,
|
|
&i.RefreshTokenExpiresAt,
|
|
&i.Nonce,
|
|
&i.UserinfoJson,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOIDCSessionBySub = `-- name: GetOIDCSessionBySub :one
|
|
SELECT sub, access_token_hash, refresh_token_hash, scope, client_id, token_expires_at, refresh_token_expires_at, nonce, userinfo_json FROM "oidc_sessions"
|
|
WHERE "sub" = $1
|
|
`
|
|
|
|
func (q *Queries) GetOIDCSessionBySub(ctx context.Context, sub string) (OidcSession, error) {
|
|
row := q.db.QueryRowContext(ctx, getOIDCSessionBySub, sub)
|
|
var i OidcSession
|
|
err := row.Scan(
|
|
&i.Sub,
|
|
&i.AccessTokenHash,
|
|
&i.RefreshTokenHash,
|
|
&i.Scope,
|
|
&i.ClientID,
|
|
&i.TokenExpiresAt,
|
|
&i.RefreshTokenExpiresAt,
|
|
&i.Nonce,
|
|
&i.UserinfoJson,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateOIDCConsent = `-- name: UpdateOIDCConsent :one
|
|
UPDATE "oidc_consent" SET
|
|
"scopes" = $1,
|
|
"updated_at" = CURRENT_TIMESTAMP
|
|
WHERE "uuid" = $2
|
|
RETURNING uuid, client_id, scopes, created_at, updated_at
|
|
`
|
|
|
|
type UpdateOIDCConsentParams struct {
|
|
Scopes string
|
|
UUID string
|
|
}
|
|
|
|
func (q *Queries) UpdateOIDCConsent(ctx context.Context, arg UpdateOIDCConsentParams) (OidcConsent, error) {
|
|
row := q.db.QueryRowContext(ctx, updateOIDCConsent, arg.Scopes, arg.UUID)
|
|
var i OidcConsent
|
|
err := row.Scan(
|
|
&i.UUID,
|
|
&i.ClientID,
|
|
&i.Scopes,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateOIDCSession = `-- name: UpdateOIDCSession :one
|
|
UPDATE "oidc_sessions" SET
|
|
"access_token_hash" = $1,
|
|
"refresh_token_hash" = $2,
|
|
"scope" = $3,
|
|
"client_id" = $4,
|
|
"token_expires_at" = $5,
|
|
"refresh_token_expires_at" = $6,
|
|
"nonce" = $7,
|
|
"userinfo_json" = $8
|
|
WHERE "sub" = $9
|
|
RETURNING sub, access_token_hash, refresh_token_hash, scope, client_id, token_expires_at, refresh_token_expires_at, nonce, userinfo_json
|
|
`
|
|
|
|
type UpdateOIDCSessionParams struct {
|
|
AccessTokenHash string
|
|
RefreshTokenHash string
|
|
Scope string
|
|
ClientID string
|
|
TokenExpiresAt int64
|
|
RefreshTokenExpiresAt int64
|
|
Nonce string
|
|
UserinfoJson string
|
|
Sub string
|
|
}
|
|
|
|
func (q *Queries) UpdateOIDCSession(ctx context.Context, arg UpdateOIDCSessionParams) (OidcSession, error) {
|
|
row := q.db.QueryRowContext(ctx, updateOIDCSession,
|
|
arg.AccessTokenHash,
|
|
arg.RefreshTokenHash,
|
|
arg.Scope,
|
|
arg.ClientID,
|
|
arg.TokenExpiresAt,
|
|
arg.RefreshTokenExpiresAt,
|
|
arg.Nonce,
|
|
arg.UserinfoJson,
|
|
arg.Sub,
|
|
)
|
|
var i OidcSession
|
|
err := row.Scan(
|
|
&i.Sub,
|
|
&i.AccessTokenHash,
|
|
&i.RefreshTokenHash,
|
|
&i.Scope,
|
|
&i.ClientID,
|
|
&i.TokenExpiresAt,
|
|
&i.RefreshTokenExpiresAt,
|
|
&i.Nonce,
|
|
&i.UserinfoJson,
|
|
)
|
|
return i, err
|
|
}
|