~bigbes/core-go

ref: 3e875f2892eaf98b699b07618d0a6eef69e1ea32 core-go/auth d---------
cc170f8f — Drew DeVault 11 months ago
Don't prevent suspended users from authenticating

With cookies or internal auth. The frontends already prevent users from
accessing services while suspended, and there are some complications if
we don't let the frontends access the backends at all if the
authenticated user is suspended.
44cf5e79 — Drew DeVault 11 months ago
auth: remove legacy OAuth support
62578ea9 — Drew DeVault 1 year, 12 days ago
auth/bearer: log username associated with expired token
1c4d7007 — Conrad Hoffmann 1 year, 21 days ago
auth: fix remote IP determination for audit log

This is probably isolated to dev or other small environments, but I had
two issues with the remote IP determination, breaking the audit log
display in my dev env after fairly standard usage.

The gist is that the audit log is designed to contain clean IP addresses
only. However, the algorithm starts out with `r.RemoteAddr`, which may
contain a port (usually 127.0.0.1:xxxxx). The port removal is already
performed at the beginning of the function, so simply re-use the result
of this.

Furthermore, the initial value (containing the port leading to breakage)
landed in the audit log because I was using a private IP (it's my dev
evn). We correctly trust private IPs, but that means if no public IP
ever shows up in the X-Forwarded-For header, the last private IP was the
one that actually made the request.

I am not entirely sure why this showed up now. I already had a bunch of
oder audit log entries that had the correct private-but-not-localhost
addresses. But in the current state, e.g. simply updating my profile
would cause the bad IP:port notation to be written to the audit log.
293ca65a — Conrad Hoffmann 1 year, 5 months ago
auth: fix middleware tests

They got broken with 6eae2199 because the tests cannot use
`config.LoadConfig`, so the list of internal IP nets never gets
populated.
d3f7b91a — Drew DeVault 1 year, 6 months ago
webhooks: implement internal webhook users

AUTH_INTERNAL requests previously could not register webhooks. This
commit adds the necessary changes to allow for this.
465a6f71 — Drew DeVault 1 year, 6 months ago
all: pass errors to panic, not strings

GraphQL's recovery middleware can't handle strings so it just logs a
very not useful <nil>
6eae2199 — Drew DeVault 1 year, 7 months ago
auth: use config.IsInternalIP
e559510f — Drew DeVault 1 year, 9 months ago
auth: reduce scope of user_type
bdf079e6 — Conrad Hoffmann 1 year, 8 months ago
auth: grant scoped access to anon internal auth

Internal auth is granted access to everything, whereas anonymous
internal auth is pretty restricted. This is mostly to avoid accidentally
hitting resolvers that require a logged-in user, however. Given that all
anon internal use cases are hard-coded and tested, this seems like a
pretty low risk. Allowing this will have the huge benefit of making much
more information available to anon internal queries, which will unlock
removing a bunch of awkward work-arounds we put in place.

Note, however, that this is also a work-around. It saves us from adding
yet more work-arounds to the GQL schema, and in the meantime a redesign
of the schema (especially the directives) is being worked on.
64b8e741 — Drew DeVault 1 year, 9 months ago
auth/middleware: fix user_type on new users
50396a55 — Drew DeVault 1 year, 9 months ago
auth/middleware: convert user types to uppercase
46a4ad6a — Drew DeVault 1 year, 10 months ago
auth: add Grants.IsSubset

This is a little bit hacky. Previously DecodeGrants would only store the
list of grants associated with the current service. This minimizes API
breakage by storing all grants as $service/$grant in the map key and
stores the local service name in the grant object, and updates
Grants.Has() to accept "$grant" and infer that it refers to a local
service or accept the fully qualified "$service/$grant" to test against
grants for any service -- which IsSubset makes use of to test that one
Grant object is a subset of another with respect to all services it has
grants for.
0d6031be — Conrad Hoffmann 1 year, 11 months ago
server: use routing groups

Instead of hardcoding some exceptions in the auth middleware, use a
different routing group for routes that do not require auth. Makes the
auth middleware more generic and also removes a lot of unneccessary
middleware processing from routes that don't need it.

For now, the added group is not accessible from outside the module, but
if the need arises, this might be an option.
bd40a71a — Drew DeVault 2 years ago
auth: add auth.IPAddress

With support for X-Forwarded-For
88dff0ea — Simon Ser 2 years ago
auth/middleware: set WWW-Authenticate header field

See RFC 6750 section 3.
864816cf — Simon Ser 2 years ago
client: rename Execute to Do

583d0b1bcb08 ("client/graphql: handle GraphQL errors") changed
Execute behavior by wrapping the result into a struct with "data"
and "errors" fields. This is a breaking change, but it's hard to
spot when upgrading core-go because it won't cause a compilation
error.

Rename Execute to Do to break the build and force callers to update
accordingly.
23808bb0 — Simon Ser 2 years ago
auth: add RequireMiddleware

Same as Middleware, but requires auth for all requests. Will be
useful to drop hacks from pages.sr.ht.
53966da2 — Simon Ser 2 years ago
Drop gqlparser v1 dependency

Only use v2 throughout the repository.
d83af997 — Simon Ser 3 years ago
auth: make DecodeGrants return an error

We'll use this function to validate grants passed in via
builds.sr.ht manifests.
Next