# @springmicro/auth

Auth config supplied for connecting with a Casdoor instance. Uses [auth-astro](https://github.com/nowaythatworked/auth-astro).

## Usage

```bash
npm i -g @springmicro/cli
springmicro add auth
```

```ts
// auth.config.ts

import { getAuthConfig } from "@springmicro/auth";

export default getAuthConfig({
  casdoorEndpoint: import.meta.env.PUBLIC_CASDOOR_ENDPOINT,
  clientId: import.meta.env.PUBLIC_CASDOOR_CLIENT_ID,
  clientSecret: import.meta.env.CASDOOR_CLIENT_SECRET,
});
```

`auth-astro` requires building your site in `server` mode with a platform adapter like `@astrojs/node`.

```bash
pnpm run astro add node
```

```js
// astro.config.mjs
export default defineConfig({
  output: "server",
  adapter: node({
    mode: "standalone",
  }),
});
```

### Casdoor

In the `application` settings, add the callback URL of `http://yourhost/callback`. Enable auto signin (optional).

## Development

### Build

```bash
pnpm run build
```

### Install in repo (locally)

```bash
# testing it out in a demo project
cd astro-demo-project
pnpm run astro add react
pnpm run astro add auth-astro
pnpm add --workspace @springmicro/auth
```
